Skip to content

Commit

Permalink
Added variables at host level and group level
Browse files Browse the repository at this point in the history
  • Loading branch information
qtkhajacloud committed Oct 14, 2021
1 parent cbee998 commit b8ce781
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
26 changes: 7 additions & 19 deletions Oct21/phpnapache/apache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- (ansible_facts['distribution'] == "CentOS" and ansible_facts['distribution_major_version'] != "7")
- name: install apache2
apt:
name: apache2
name: {{ package }}
update_cache: yes
state: present
when:
Expand All @@ -31,7 +31,7 @@
- ansible_facts['distribution_major_version'] == "20"
- name: install httpd
yum:
name: httpd
name: {{ package }}
state: present
when:
- ansible_facts['distribution'] == "CentOS"
Expand All @@ -44,34 +44,22 @@
- php-mysql
state: present
notify:
- Restart Httpd
- Restart Apache
when:
- ansible_facts['distribution'] == "CentOS"
- ansible_facts['distribution_major_version'] == "7"
- name: create info.php
copy:
dest: /var/www/html/info.php
dest: {{ info_location }}
content: |
<?php
phpinfo();
?>
notify:
- Restart Apache2
- Restart Httpd
- Restart Apache
handlers:
- name: Restart Apache2
- name: Restart Apache
service:
name: apache2
name: {{ package }}
enabled: yes
state: restarted
when:
- ansible_facts['distribution'] == "Ubuntu"
- ansible_facts['distribution_major_version'] == "20"
- name: Restart Httpd
service:
name: httpd
enabled: yes
state: restarted
when:
- ansible_facts['distribution'] == "CentOS"
- ansible_facts['distribution_major_version'] == "7"
7 changes: 5 additions & 2 deletions Oct21/phpnapache/inventory
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[webserver]
172.31.17.152
172.31.29.133
172.31.17.152 package=apache2
172.31.29.133 package=httpd

[webserver:vars]
info_location=/var/www/html/info.php

[dbserver]
172.31.29.133
Expand Down

0 comments on commit b8ce781

Please sign in to comment.