|
| 1 | +--- |
| 2 | +- name: Validate and fetch proxy prerequisites |
| 3 | + hosts: quadlet |
| 4 | + become: true |
| 5 | + vars_files: |
| 6 | + - "../../vars/certificates.yml" |
| 7 | + - "../../vars/foreman.yml" |
| 8 | + tasks: |
| 9 | + - name: Check certificate bundle exists |
| 10 | + ansible.builtin.stat: |
| 11 | + path: "{{ certificates_ca_directory }}/bundles/{{ hostname }}.tar.gz" |
| 12 | + register: _bundle_stat |
| 13 | + |
| 14 | + - name: Fail if certificate bundle does not exist |
| 15 | + ansible.builtin.fail: |
| 16 | + msg: >- |
| 17 | + Certificate bundle for {{ hostname }} not found at |
| 18 | + {{ certificates_ca_directory }}/bundles/{{ hostname }}.tar.gz. |
| 19 | + Run 'foremanctl certificate-bundle --hostname {{ hostname }}' first. |
| 20 | + when: not _bundle_stat.stat.exists |
| 21 | + |
| 22 | + - name: Fetch certificate bundle to controller |
| 23 | + ansible.builtin.fetch: |
| 24 | + src: "{{ certificates_ca_directory }}/bundles/{{ hostname }}.tar.gz" |
| 25 | + dest: "{{ obsah_state_path }}/{{ hostname }}.tar.gz" |
| 26 | + flat: true |
| 27 | + |
| 28 | + - name: Add proxy host to inventory |
| 29 | + ansible.builtin.add_host: |
| 30 | + name: "{{ hostname }}" |
| 31 | + groups: proxy |
| 32 | + ansible_connection: ssh |
| 33 | + ansible_host: "{{ hostname }}" |
| 34 | + ansible_user: "{{ proxy_ssh_user | default('root') }}" |
| 35 | + inventory_dir: "{{ inventory_dir }}" |
| 36 | + |
| 37 | +- name: Transfer proxy certificate bundle and oauth credentials to proxy host |
| 38 | + hosts: proxy |
| 39 | + become: true |
| 40 | + vars_files: |
| 41 | + - "../../vars/foreman.yml" |
| 42 | + tasks: |
| 43 | + - name: Check SSH connectivity and authentication to proxy |
| 44 | + ansible.builtin.ping: |
| 45 | + |
| 46 | + - name: Copy certificate bundle to proxy |
| 47 | + ansible.builtin.copy: |
| 48 | + src: "{{ obsah_state_path }}/{{ hostname }}.tar.gz" |
| 49 | + dest: "/root/{{ hostname }}.tar.gz" |
| 50 | + mode: "0600" |
| 51 | + owner: root |
| 52 | + group: root |
| 53 | + |
| 54 | + - name: Copy OAuth consumer key to proxy |
| 55 | + ansible.builtin.copy: |
| 56 | + src: "{{ foreman_oauth_consumer_key_file }}" |
| 57 | + dest: "/root/foreman-oauth-consumer-key" |
| 58 | + mode: "0600" |
| 59 | + owner: root |
| 60 | + group: root |
| 61 | + |
| 62 | + - name: Copy OAuth consumer secret to proxy |
| 63 | + ansible.builtin.copy: |
| 64 | + src: "{{ foreman_oauth_consumer_secret_file }}" |
| 65 | + dest: "/root/foreman-oauth-consumer-secret" |
| 66 | + mode: "0600" |
| 67 | + owner: root |
| 68 | + group: root |
0 commit comments