| Andrea Frittoli (andreaf) | 9c977b5 | 2017-12-08 17:41:40 +0000 | [diff] [blame] | 1 | - name: Ensure {{ stage_dir }}/apache exists |
| 2 | file: |
| 3 | path: "{{ stage_dir }}/apache" |
| 4 | state: directory |
| 5 | |
| 6 | - name: Link apache logs on Debian/SuSE |
| 7 | block: |
| 8 | - name: Find logs |
| 9 | find: |
| 10 | path: "/var/log/apache2" |
| 11 | file_type: any |
| 12 | register: debian_suse_apache_logs |
| 13 | - name: Dereference files |
| 14 | stat: |
| 15 | path: "{{ item.path }}" |
| 16 | with_items: "{{ debian_suse_apache_logs.files }}" |
| 17 | register: debian_suse_apache_deref_logs |
| 18 | - name: Create hard links |
| 19 | file: |
| 20 | src: "{{ item.stat.lnk_source | default(item.stat.path) }}" |
| 21 | dest: "{{ stage_dir }}/apache/{{ item.stat.path | basename }}" |
| 22 | state: hard |
| 23 | with_items: "{{ debian_suse_apache_deref_logs.results }}" |
| 24 | when: |
| 25 | - item.stat.isreg or item.stat.islnk |
| 26 | when: ansible_os_family in ('Debian', 'Suse') |
| 27 | |
| 28 | - name: Link apache logs on RedHat |
| 29 | block: |
| 30 | - name: Find logs |
| 31 | find: |
| 32 | path: "/var/log/httpd" |
| 33 | file_type: any |
| 34 | register: redhat_apache_logs |
| 35 | - name: Dereference files |
| 36 | stat: |
| 37 | path: "{{ item.path }}" |
| 38 | with_items: "{{ redhat_apache_logs.files }}" |
| 39 | register: redhat_apache_deref_logs |
| 40 | - name: Create hard links |
| 41 | file: |
| 42 | src: "{{ item.stat.lnk_source | default(item.stat.path) }}" |
| 43 | dest: "{{ stage_dir }}/apache/{{ item.stat.path | basename }}" |
| 44 | state: hard |
| 45 | with_items: "{{ redhat_apache_deref_logs.results }}" |
| 46 | when: |
| 47 | - item.stat.isreg or item.stat.islnk |
| 48 | when: ansible_os_family == 'Redhat' |
| 49 | |
| 50 | - name: Ensure {{ stage_dir }}/apache_config apache_config exists |
| 51 | file: |
| 52 | path: "{{ stage_dir }}/apache_config" |
| 53 | state: directory |
| 54 | |
| 55 | - name: Define config paths |
| 56 | set_fact: |
| 57 | apache_config_paths: |
| 58 | 'Debian': '/etc/apache2/sites-enabled/' |
| 59 | 'Suse': '/etc/apache2/conf.d/' |
| Daniel Mellado | 2e9e90b | 2018-02-20 12:17:55 +0100 | [diff] [blame^] | 60 | 'RedHat': '/etc/httpd/conf.d/' |
| Andrea Frittoli (andreaf) | 9c977b5 | 2017-12-08 17:41:40 +0000 | [diff] [blame] | 61 | |
| 62 | - name: Discover configurations |
| 63 | find: |
| 64 | path: "{{ apache_config_paths[ansible_os_family] }}" |
| 65 | file_type: any |
| 66 | register: apache_configs |
| Andrea Frittoli | 0f39756 | 2018-02-02 17:03:24 +0000 | [diff] [blame] | 67 | no_log: true |
| Andrea Frittoli (andreaf) | 9c977b5 | 2017-12-08 17:41:40 +0000 | [diff] [blame] | 68 | |
| 69 | - name: Dereference configurations |
| 70 | stat: |
| 71 | path: "{{ item.path }}" |
| 72 | with_items: "{{ apache_configs.files }}" |
| 73 | register: apache_configs_deref |
| Andrea Frittoli | 0f39756 | 2018-02-02 17:03:24 +0000 | [diff] [blame] | 74 | no_log: true |
| Andrea Frittoli (andreaf) | 9c977b5 | 2017-12-08 17:41:40 +0000 | [diff] [blame] | 75 | |
| 76 | - name: Link configurations |
| 77 | file: |
| 78 | src: "{{ item.stat.lnk_source | default(item.stat.path) }}" |
| 79 | dest: "{{ stage_dir }}/apache_config/{{ item.stat.path | basename }}" |
| 80 | state: hard |
| 81 | with_items: "{{ apache_configs_deref.results }}" |
| 82 | when: item.stat.isreg or item.stat.islnk |
| Andrea Frittoli | 0f39756 | 2018-02-02 17:03:24 +0000 | [diff] [blame] | 83 | no_log: true |