--- - name: Create custom theme folder file: path: /usr/src/nagios4_theme state: directory owner: www-data group: www-data - name: Get theme unarchive: remote_src: true src: "{{ custom_theme_url }}" dest: /usr/src/nagios4_theme list_files: true owner: www-data group: www-data register: zip_files - name: Set permissions to custom theme folder file: path: "/usr/src/nagios4_theme/{{ zip_files.files[0] }}" state: directory owner: www-data group: www-data - name: Get current stylesheets stats stat: path: /etc/nagios4/stylesheets register: stylesheets - name: Copy old stylesheets copy: remote_src: true src: /etc/nagios4/stylesheets dest: /etc/nagios4/stylesheets_original when: stylesheets.stat.isdir is defined and stylesheets.stat.isdir - name: Remove old stylesheets file: state: absent path: /etc/nagios4/stylesheets when: stylesheets.stat.isdir is defined and stylesheets.stat.isdir - name: Create link to custom theme file: state: link path: /etc/nagios4/stylesheets src: /usr/src/nagios4_theme/{{ zip_files.files[0] }}/stylesheets owner: www-data group: www-data - name: Get custom theme index.php stats stat: path: /usr/src/nagios4_theme//{{ zip_files.files[0] }}/index.php register: index_php - name: Backup previous index.php copy: remote_src: true src: /usr/share/nagios4/htdocs/index.php dest: /usr/share/nagios4/htdocs/index_previous.php when: index_php.stat.exists - name: Copy custom index.php copy: remote_src: true src: /usr/src/nagios4_theme//{{ zip_files.files[0] }}/index.php dest: /usr/share/nagios4/htdocs/index.php when: index_php.stat.exists