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 |
| 8 | become: true |
| 9 | |
Bartek Grzybowski | 22bb23f | 2019-02-22 16:10:27 +0100 | [diff] [blame] | 10 | - name: Disable all OS default repositories |
| 11 | block: |
| 12 | - name: Find repo files names |
| 13 | find: |
| 14 | paths: /etc/yum.repos.d |
| 15 | pattern: '*.repo' |
| 16 | register: repo_files |
| 17 | |
| 18 | - name: Get all defined offline repo names |
| 19 | set_fact: package_repositories_names="{{ package_repositories | selectattr('name', 'defined') | map(attribute='name') | list }}" |
| 20 | |
| 21 | - name: Backup repo files |
| 22 | copy: |
| 23 | remote_src: yes |
| 24 | src: "{{ item.path }}" |
| 25 | dest: "{{ item.path }}.disabled" |
| 26 | loop: "{{ repo_files.files }}" |
| 27 | when: "(item.path | basename | splitext)[0] not in package_repositories_names" |
| 28 | |
| 29 | - name: Remove disabled repo files |
| 30 | file: |
| 31 | path: "{{ item.path }}" |
| 32 | state: absent |
| 33 | loop: "{{ repo_files.files }}" |
| 34 | when: "(item.path | basename | splitext)[0] not in package_repositories_names" |
| 35 | become: yes |
| 36 | |
Samuli Silvius | 79bfeda | 2019-02-12 21:08:26 +0200 | [diff] [blame] | 37 | - name: Add application offline package repository |
| 38 | yum_repository: |
Bartek Grzybowski | 22bb23f | 2019-02-22 16:10:27 +0100 | [diff] [blame] | 39 | name: "{{ item.name }}" |
| 40 | file: "{{ item.file }}" |
| 41 | description: "{{ item.description | default('') }}" |
| 42 | baseurl: "{{ item.baseurl | default('') }}" |
| 43 | gpgcheck: "{{ item.gpgcheck | default(true) }}" |
| 44 | enabled: "{{ item.enabled | default(false) }}" |
| 45 | state: "{{ item.state | default('present') }}" |
| 46 | loop: "{{ package_repositories }}" |
Samuli Silvius | 79bfeda | 2019-02-12 21:08:26 +0200 | [diff] [blame] | 47 | become: true |