diff --git a/README.md b/README.md index 797731506..6430aca96 100644 --- a/README.md +++ b/README.md @@ -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 ---------------- diff --git a/lamp_simple/group_vars/all b/lamp_simple/group_vars/all index 74ca4581c..541af4d82 100644 --- a/lamp_simple/group_vars/all +++ b/lamp_simple/group_vars/all @@ -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 diff --git a/lamp_simple/roles/common/handlers/main.yml b/lamp_simple/roles/common/handlers/main.yml index 89e2374fe..9e4aaa63a 100644 --- a/lamp_simple/roles/common/handlers/main.yml +++ b/lamp_simple/roles/common/handlers/main.yml @@ -4,5 +4,5 @@ - name: restart ntp service: - name: ntpd + name: chronyd state: restarted diff --git a/lamp_simple/roles/common/tasks/main.yml b/lamp_simple/roles/common/tasks/main.yml index ceef3da09..0db7e2c4c 100644 --- a/lamp_simple/roles/common/tasks/main.yml +++ b/lamp_simple/roles/common/tasks/main.yml @@ -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 diff --git a/lamp_simple/roles/common/templates/chrony.conf.j2 b/lamp_simple/roles/common/templates/chrony.conf.j2 new file mode 100644 index 000000000..06672ac42 --- /dev/null +++ b/lamp_simple/roles/common/templates/chrony.conf.j2 @@ -0,0 +1,5 @@ +pool {{ chronypool }} iburst +driftfile /var/lib/chrony/drift +makestep 1.0 3 +rtcsync +leapsectz right/UTC diff --git a/lamp_simple/roles/common/templates/ntp.conf.j2 b/lamp_simple/roles/common/templates/ntp.conf.j2 deleted file mode 100644 index 6336c2ea3..000000000 --- a/lamp_simple/roles/common/templates/ntp.conf.j2 +++ /dev/null @@ -1,12 +0,0 @@ - -driftfile /var/lib/ntp/drift - -restrict 127.0.0.1 -restrict -6 ::1 - -server {{ ntpserver }} - -includefile /etc/ntp/crypto/pw - -keys /etc/ntp/keys - diff --git a/lamp_simple/roles/db/handlers/main.yml b/lamp_simple/roles/db/handlers/main.yml index 43e3c9a5d..1cd1ec809 100644 --- a/lamp_simple/roles/db/handlers/main.yml +++ b/lamp_simple/roles/db/handlers/main.yml @@ -6,7 +6,7 @@ name: mysqld state: restarted -- name: restart iptables +- name: restart firewalld service: - name: iptables + name: firewalld state: restarted diff --git a/lamp_simple/roles/db/tasks/main.yml b/lamp_simple/roles/db/tasks/main.yml index 2afc4061c..7498419b7 100644 --- a/lamp_simple/roles/db/tasks/main.yml +++ b/lamp_simple/roles/db/tasks/main.yml @@ -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: @@ -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: "^" + line: ' ' + notify: restart firewalld - name: Create Application Database mysql_db: diff --git a/lamp_simple/roles/web/handlers/main.yml b/lamp_simple/roles/web/handlers/main.yml index 52ef3c90d..25effcd02 100644 --- a/lamp_simple/roles/web/handlers/main.yml +++ b/lamp_simple/roles/web/handlers/main.yml @@ -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 diff --git a/lamp_simple/roles/web/tasks/install_httpd.yml b/lamp_simple/roles/web/tasks/install_httpd.yml index 4de593d95..ac77ad969 100644 --- a/lamp_simple/roles/web/tasks/install_httpd.yml +++ b/lamp_simple/roles/web/tasks/install_httpd.yml @@ -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: "^" + line: ' ' + notify: restart firewalld - name: http service state service: