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 orhttpd
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 orhttpd
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 orhttpd
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 orhttpd
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,70821939
6,70821939
asked Nov 11 at 20:53
Smi
264
264
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 |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
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,70821939
6,70821939
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