Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Update lamp_simple example to CentOS 8 #303

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
This repository is forked from https://github.com/ansible/ansible-examples and
includes changes to the `lamp_simple` example in order to make it work with CentOS 8 servers.


Ansible Examples
----------------
Expand Down
2 changes: 1 addition & 1 deletion lamp_simple/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Variables listed here are applicable to all host groups

httpd_port: 80
ntpserver: 192.168.1.2
chronypool: 2.fedora.pool.ntp.org
repository: https://github.com/bennojoy/mywebapp.git
2 changes: 1 addition & 1 deletion lamp_simple/roles/common/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

- name: restart ntp
service:
name: ntpd
name: chronyd
state: restarted
12 changes: 6 additions & 6 deletions lamp_simple/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
# This playbook contains common plays that will be run on all nodes.

- name: Install ntp
- name: Install chrony
yum:
name: ntp
name: chrony
state: present
tags: ntp

- name: Configure ntp file
- name: Configure chrony file
template:
src: ntp.conf.j2
dest: /etc/ntp.conf
src: chrony.conf.j2
dest: /etc/chrony.conf
tags: ntp
notify: restart ntp

- name: Start the ntp service
service:
name: ntpd
name: chronyd
state: started
enabled: yes
tags: ntp
Expand Down
5 changes: 5 additions & 0 deletions lamp_simple/roles/common/templates/chrony.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pool {{ chronypool }} iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
leapsectz right/UTC
12 changes: 0 additions & 12 deletions lamp_simple/roles/common/templates/ntp.conf.j2

This file was deleted.

4 changes: 2 additions & 2 deletions lamp_simple/roles/db/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name: mysqld
state: restarted

- name: restart iptables
- name: restart firewalld
service:
name: iptables
name: firewalld
state: restarted
18 changes: 9 additions & 9 deletions lamp_simple/roles/db/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
name: "{{ item }}"
state: installed
with_items:
- mysql-server
- MySQL-python
- libselinux-python
- libsemanage-python
- mysql-server
- python3-mysql
- python3-libselinux
- python3-libsemanage

- name: Configure SELinux to start mysql on any port
seboolean:
Expand All @@ -33,12 +33,12 @@

- name: insert iptables rule
lineinfile:
dest: /etc/sysconfig/iptables
dest: /etc/firewalld/zones/public.xml
state: present
regexp: "{{ mysql_port }}"
insertafter: "^:OUTPUT "
line: "-A INPUT -p tcp --dport {{ mysql_port }} -j ACCEPT"
notify: restart iptables
regexp: 'port="{{ mysql_port }}".*protocol="tcp"'
insertbefore: "^</zone>"
line: ' <port port="{{ mysql_port }}" protocol="tcp"/>'
notify: restart firewalld

- name: Create Application Database
mysql_db:
Expand Down
4 changes: 2 additions & 2 deletions lamp_simple/roles/web/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Handler for the webtier: handlers are called by other plays.
# See http://docs.ansible.com/playbooks_intro.html for more information about handlers.

- name: restart iptables
- name: restart firewalld
service:
name: iptables
name: firewalld
state: restarted
25 changes: 12 additions & 13 deletions lamp_simple/roles/web/tasks/install_httpd.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
---
# These tasks install http and the php modules.

- name: Install http and php etc
- name: Install httpd and php etc
yum:
name: "{{ item }}"
state: present
with_items:
- httpd
- php
- php-mysql
- git
- libsemanage-python
- libselinux-python
- httpd
- php
- php-mysqlnd
- git
- python3-libsemanage
- python3-libselinux

- name: insert iptables rule for httpd
lineinfile:
dest: /etc/sysconfig/iptables
create: yes
dest: /etc/firewalld/zones/public.xml
state: present
regexp: "{{ httpd_port }}"
insertafter: "^:OUTPUT "
line: "-A INPUT -p tcp --dport {{ httpd_port }} -j ACCEPT"
notify: restart iptables
regexp: 'port="{{ httpd_port }}".*protocol="tcp"'
insertbefore: "^</zone>"
line: ' <port port="{{ httpd_port }}" protocol="tcp"/>'
notify: restart firewalld

- name: http service state
service:
Expand Down