Platform Independent Manifest to install and run apache2 or httpd
up vote
2
down vote
favorite
I need to write a single manifest as install-apache.pp
that will install
apache2
package if it is Debian based system or
httpd
package if it is RedHat based system
Below is the code; this works in CentOS but does not work in Ubuntu.
case $facts['os']['name'] {
'Debian': {
package { 'apache2':
ensure => installed,
}
service { 'apache2':
ensure => running,
}
}
'RedHat': {
package { 'httpd' :
ensure => installed,
}
service { 'httpd':
ensure => running,
}
}
}
So I made some changes as below, but am not sure why it is not working.
case $operatingsystem {
'Debian': {
package { 'apache2':
ensure => installed,
} ->
service { 'apache2':
ensure => running,
enable => true,
}
}
'RedHat': {
package { 'httpd' :
ensure => installed,
} ->
service { 'httpd':
ensure => running,
enable => true,
}
}
}
Command used to execute:
puppet apply install-apache.pp --logdest /root/output.log
puppet puppet-enterprise puppetlabs-apache
add a comment |
up vote
2
down vote
favorite
I need to write a single manifest as install-apache.pp
that will install
apache2
package if it is Debian based system or
httpd
package if it is RedHat based system
Below is the code; this works in CentOS but does not work in Ubuntu.
case $facts['os']['name'] {
'Debian': {
package { 'apache2':
ensure => installed,
}
service { 'apache2':
ensure => running,
}
}
'RedHat': {
package { 'httpd' :
ensure => installed,
}
service { 'httpd':
ensure => running,
}
}
}
So I made some changes as below, but am not sure why it is not working.
case $operatingsystem {
'Debian': {
package { 'apache2':
ensure => installed,
} ->
service { 'apache2':
ensure => running,
enable => true,
}
}
'RedHat': {
package { 'httpd' :
ensure => installed,
} ->
service { 'httpd':
ensure => running,
enable => true,
}
}
}
Command used to execute:
puppet apply install-apache.pp --logdest /root/output.log
puppet puppet-enterprise puppetlabs-apache
You'll need to provide more information about what the problem is.
– Alex Harvey
Nov 12 at 12:37
2
Have you considered using the puppetlabs/apache module, available from the Forge? I mean, reinventing the wheel is great and all, but -- actually, no, it's not that great.
– John Bollinger
Nov 13 at 3:27
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I need to write a single manifest as install-apache.pp
that will install
apache2
package if it is Debian based system or
httpd
package if it is RedHat based system
Below is the code; this works in CentOS but does not work in Ubuntu.
case $facts['os']['name'] {
'Debian': {
package { 'apache2':
ensure => installed,
}
service { 'apache2':
ensure => running,
}
}
'RedHat': {
package { 'httpd' :
ensure => installed,
}
service { 'httpd':
ensure => running,
}
}
}
So I made some changes as below, but am not sure why it is not working.
case $operatingsystem {
'Debian': {
package { 'apache2':
ensure => installed,
} ->
service { 'apache2':
ensure => running,
enable => true,
}
}
'RedHat': {
package { 'httpd' :
ensure => installed,
} ->
service { 'httpd':
ensure => running,
enable => true,
}
}
}
Command used to execute:
puppet apply install-apache.pp --logdest /root/output.log
puppet puppet-enterprise puppetlabs-apache
I need to write a single manifest as install-apache.pp
that will install
apache2
package if it is Debian based system or
httpd
package if it is RedHat based system
Below is the code; this works in CentOS but does not work in Ubuntu.
case $facts['os']['name'] {
'Debian': {
package { 'apache2':
ensure => installed,
}
service { 'apache2':
ensure => running,
}
}
'RedHat': {
package { 'httpd' :
ensure => installed,
}
service { 'httpd':
ensure => running,
}
}
}
So I made some changes as below, but am not sure why it is not working.
case $operatingsystem {
'Debian': {
package { 'apache2':
ensure => installed,
} ->
service { 'apache2':
ensure => running,
enable => true,
}
}
'RedHat': {
package { 'httpd' :
ensure => installed,
} ->
service { 'httpd':
ensure => running,
enable => true,
}
}
}
Command used to execute:
puppet apply install-apache.pp --logdest /root/output.log
puppet puppet-enterprise puppetlabs-apache
puppet puppet-enterprise puppetlabs-apache
edited Nov 12 at 13:40
Matt Schuchard
6,67321939
6,67321939
asked Nov 11 at 20:53
Smi
214
214
You'll need to provide more information about what the problem is.
– Alex Harvey
Nov 12 at 12:37
2
Have you considered using the puppetlabs/apache module, available from the Forge? I mean, reinventing the wheel is great and all, but -- actually, no, it's not that great.
– John Bollinger
Nov 13 at 3:27
add a comment |
You'll need to provide more information about what the problem is.
– Alex Harvey
Nov 12 at 12:37
2
Have you considered using the puppetlabs/apache module, available from the Forge? I mean, reinventing the wheel is great and all, but -- actually, no, it's not that great.
– John Bollinger
Nov 13 at 3:27
You'll need to provide more information about what the problem is.
– Alex Harvey
Nov 12 at 12:37
You'll need to provide more information about what the problem is.
– Alex Harvey
Nov 12 at 12:37
2
2
Have you considered using the puppetlabs/apache module, available from the Forge? I mean, reinventing the wheel is great and all, but -- actually, no, it's not that great.
– John Bollinger
Nov 13 at 3:27
Have you considered using the puppetlabs/apache module, available from the Forge? I mean, reinventing the wheel is great and all, but -- actually, no, it's not that great.
– John Bollinger
Nov 13 at 3:27
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
The problem here is that you are making use of the fact $facts['os']['name']
which is assigned the specific operating system of the distribution and not the family of the distribution. That fact will be assigned Ubuntu
on Ubuntu and not Debian
. The fact needs to be fixed to $facts['os']['family']
, which will be assigned Debian
on Ubuntu.
You can also make use of selectors to improve this a bit more in addition to the fix. It is also recommended to construct a dependency of the service
on the package
in that manifest to ensure proper ordering. Refreshing would also be helpful.
With those fixes and improvements in mind, your final manifest would look like:
$web_service = $facts['os']['family'] ? {
'RedHat' => 'httpd',
'Debian' => 'apache2',
default => fail('Unsupported operating system.'),
}
package { $web_service:
ensure => installed,
}
~> service { $web_service:
ensure => running,
enable => true,
}
Thanks Matt......
– Smi
Nov 13 at 15:52
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
The problem here is that you are making use of the fact $facts['os']['name']
which is assigned the specific operating system of the distribution and not the family of the distribution. That fact will be assigned Ubuntu
on Ubuntu and not Debian
. The fact needs to be fixed to $facts['os']['family']
, which will be assigned Debian
on Ubuntu.
You can also make use of selectors to improve this a bit more in addition to the fix. It is also recommended to construct a dependency of the service
on the package
in that manifest to ensure proper ordering. Refreshing would also be helpful.
With those fixes and improvements in mind, your final manifest would look like:
$web_service = $facts['os']['family'] ? {
'RedHat' => 'httpd',
'Debian' => 'apache2',
default => fail('Unsupported operating system.'),
}
package { $web_service:
ensure => installed,
}
~> service { $web_service:
ensure => running,
enable => true,
}
Thanks Matt......
– Smi
Nov 13 at 15:52
add a comment |
up vote
3
down vote
accepted
The problem here is that you are making use of the fact $facts['os']['name']
which is assigned the specific operating system of the distribution and not the family of the distribution. That fact will be assigned Ubuntu
on Ubuntu and not Debian
. The fact needs to be fixed to $facts['os']['family']
, which will be assigned Debian
on Ubuntu.
You can also make use of selectors to improve this a bit more in addition to the fix. It is also recommended to construct a dependency of the service
on the package
in that manifest to ensure proper ordering. Refreshing would also be helpful.
With those fixes and improvements in mind, your final manifest would look like:
$web_service = $facts['os']['family'] ? {
'RedHat' => 'httpd',
'Debian' => 'apache2',
default => fail('Unsupported operating system.'),
}
package { $web_service:
ensure => installed,
}
~> service { $web_service:
ensure => running,
enable => true,
}
Thanks Matt......
– Smi
Nov 13 at 15:52
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
The problem here is that you are making use of the fact $facts['os']['name']
which is assigned the specific operating system of the distribution and not the family of the distribution. That fact will be assigned Ubuntu
on Ubuntu and not Debian
. The fact needs to be fixed to $facts['os']['family']
, which will be assigned Debian
on Ubuntu.
You can also make use of selectors to improve this a bit more in addition to the fix. It is also recommended to construct a dependency of the service
on the package
in that manifest to ensure proper ordering. Refreshing would also be helpful.
With those fixes and improvements in mind, your final manifest would look like:
$web_service = $facts['os']['family'] ? {
'RedHat' => 'httpd',
'Debian' => 'apache2',
default => fail('Unsupported operating system.'),
}
package { $web_service:
ensure => installed,
}
~> service { $web_service:
ensure => running,
enable => true,
}
The problem here is that you are making use of the fact $facts['os']['name']
which is assigned the specific operating system of the distribution and not the family of the distribution. That fact will be assigned Ubuntu
on Ubuntu and not Debian
. The fact needs to be fixed to $facts['os']['family']
, which will be assigned Debian
on Ubuntu.
You can also make use of selectors to improve this a bit more in addition to the fix. It is also recommended to construct a dependency of the service
on the package
in that manifest to ensure proper ordering. Refreshing would also be helpful.
With those fixes and improvements in mind, your final manifest would look like:
$web_service = $facts['os']['family'] ? {
'RedHat' => 'httpd',
'Debian' => 'apache2',
default => fail('Unsupported operating system.'),
}
package { $web_service:
ensure => installed,
}
~> service { $web_service:
ensure => running,
enable => true,
}
answered Nov 12 at 13:36
Matt Schuchard
6,67321939
6,67321939
Thanks Matt......
– Smi
Nov 13 at 15:52
add a comment |
Thanks Matt......
– Smi
Nov 13 at 15:52
Thanks Matt......
– Smi
Nov 13 at 15:52
Thanks Matt......
– Smi
Nov 13 at 15:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253135%2fplatform-independent-manifest-to-install-and-run-apache2-or-httpd%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You'll need to provide more information about what the problem is.
– Alex Harvey
Nov 12 at 12:37
2
Have you considered using the puppetlabs/apache module, available from the Forge? I mean, reinventing the wheel is great and all, but -- actually, no, it's not that great.
– John Bollinger
Nov 13 at 3:27