Samuli Silvius | 79bfeda | 2019-02-12 21:08:26 +0200 | [diff] [blame] | 1 | --- |
| 2 | - name: Setup resolv.conf for node to find package repository by name from infra |
| 3 | lineinfile: |
| 4 | line: "nameserver {{ hostvars[groups.infrastructure[0]].cluster_ip }}" |
| 5 | path: /etc/resolv.conf |
| 6 | state: present |
| 7 | insertbefore: BOF |
Samuli Silvius | 79bfeda | 2019-02-12 21:08:26 +0200 | [diff] [blame] | 8 | |
Bartek Grzybowski | 22bb23f | 2019-02-22 16:10:27 +0100 | [diff] [blame] | 9 | - name: Disable all OS default repositories |
| 10 | block: |
| 11 | - name: Find repo files names |
| 12 | find: |
| 13 | paths: /etc/yum.repos.d |
| 14 | pattern: '*.repo' |
| 15 | register: repo_files |
| 16 | |
| 17 | - name: Get all defined offline repo names |
| 18 | set_fact: package_repositories_names="{{ package_repositories | selectattr('name', 'defined') | map(attribute='name') | list }}" |
| 19 | |
| 20 | - name: Backup repo files |
| 21 | copy: |
Samuli Silvius | b3acc41 | 2019-03-22 15:37:39 +0200 | [diff] [blame] | 22 | remote_src: true |
Bartek Grzybowski | 22bb23f | 2019-02-22 16:10:27 +0100 | [diff] [blame] | 23 | src: "{{ item.path }}" |
| 24 | dest: "{{ item.path }}.disabled" |
| 25 | loop: "{{ repo_files.files }}" |
| 26 | when: "(item.path | basename | splitext)[0] not in package_repositories_names" |
| 27 | |
| 28 | - name: Remove disabled repo files |
| 29 | file: |
| 30 | path: "{{ item.path }}" |
| 31 | state: absent |
| 32 | loop: "{{ repo_files.files }}" |
| 33 | when: "(item.path | basename | splitext)[0] not in package_repositories_names" |
Bartek Grzybowski | 22bb23f | 2019-02-22 16:10:27 +0100 | [diff] [blame] | 34 | |
Samuli Silvius | 79bfeda | 2019-02-12 21:08:26 +0200 | [diff] [blame] | 35 | - name: Add application offline package repository |
| 36 | yum_repository: |
Bartek Grzybowski | 22bb23f | 2019-02-22 16:10:27 +0100 | [diff] [blame] | 37 | name: "{{ item.name }}" |
| 38 | file: "{{ item.file }}" |
| 39 | description: "{{ item.description | default('') }}" |
| 40 | baseurl: "{{ item.baseurl | default('') }}" |
| 41 | gpgcheck: "{{ item.gpgcheck | default(true) }}" |
| 42 | enabled: "{{ item.enabled | default(false) }}" |
| 43 | state: "{{ item.state | default('present') }}" |
| 44 | loop: "{{ package_repositories }}" |