diff --git a/inventory.ini b/inventory.ini index 27a177c..32af932 100644 --- a/inventory.ini +++ b/inventory.ini @@ -1,6 +1,6 @@ [node] -node1 ansible_host=172.17.33.191 nginx_user=www-data -node2 ansible_host=172.17.33.206 nginx_user=root +node1 ansible_host=172.17.35.153 nginx_user=www-data +node2 ansible_host=172.17.33.254 nginx_user=root [all:vars] ansible_user = cloudadmin diff --git a/playbook.yaml b/playbook.yaml index c8a9f03..d1c176f 100644 --- a/playbook.yaml +++ b/playbook.yaml @@ -1,40 +1,9 @@ --- -- name: Update packeges +- name: Update packages hosts: node become: yes - tasks: - - name: Update all packages Ubuntu - when: ansible_os_family == 'Debian' - apt: - update_cache: yes - upgrade: yes - - - name: Update all packages CentOS - when: ansible_os_family == 'RedHat' - yum: - name: '*' - state: latest - - - name: Install nginx 'Ubuntu' - when: ansible_os_family == 'Debian' - ansible.builtin.apt: - package: - - nginx - state: present - update_cache: yes - - - name: Install nginx 'RedHat' - when: ansible_os_family == 'RedHat' - ansible.builtin.yum: - name: - - nginx - state: present - - - name: Copy config nginx - ansible.builtin.template: - src: nginx.conf.j2 - dest: /etc/nginx/nginx.conf - + roles: + - role: ./tsm_labs diff --git a/tsm_labs/handlers/main.yml b/tsm_labs/handlers/main.yml index dc4e54a..0864fc8 100644 --- a/tsm_labs/handlers/main.yml +++ b/tsm_labs/handlers/main.yml @@ -1,12 +1,12 @@ --- # handlers file for itt_labs - name: Enable nginx service - ansible.builtin.systemd_service: - name: "nginx.service" + ansible.builtin.systemd: + name: nginx.service state: restarted enabled: true - name: Reload nginx service - ansible.builtin.systemd_service: - name: "nginx.service" + ansible.builtin.systemd: + name: nginx.service state: restarted diff --git a/tsm_labs/tasks/main.yml b/tsm_labs/tasks/main.yml index 980ae93..61b1256 100644 --- a/tsm_labs/tasks/main.yml +++ b/tsm_labs/tasks/main.yml @@ -1,8 +1,4 @@ --- -- name: Update packeges - hosts: node - become: yes - tasks: - name: Update all packages Ubuntu when: ansible_os_family == 'Debian' apt: @@ -36,7 +32,7 @@ dest: /etc/nginx/nginx.conf owner: root group: root - made: '0644' + mode: '0644' notify: Reload nginx service