Skip to content

Commit 23aa65d

Browse files
author
Arvind Jangir
committed
prepare proxy before deployment
1 parent a365641 commit 23aa65d

7 files changed

Lines changed: 102 additions & 9 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,14 @@ jobs:
449449
./foremanctl certificate-bundle proxy.example.com \
450450
--certificate-source=${{ matrix.certificate_source }} \
451451
${{ matrix.certificate_source == 'custom_server' && '--certificate-server-certificate /root/custom-certificates/certs/proxy.example.com.crt --certificate-server-key /root/custom-certificates/private/proxy.example.com.key' || '' }}
452-
- name: Fetch certificates bundle from quadlet
452+
- name: Prepare proxy host
453453
run: |
454-
./forge fetch-bundle proxy.example.com
454+
./foremanctl prepare-proxy proxy.example.com
455455
- name: Deploy content proxy
456456
run: |
457457
./foremanctl deploy-proxy \
458458
--flavor foreman-proxy-content \
459-
--certificate-bundle $(pwd)/.var/lib/foremanctl/proxy.example.com.tar.gz \
459+
--certificate-bundle /root/proxy.example.com.tar.gz \
460460
--foreman-fqdn quadlet.example.com
461461
- name: Run tests
462462
run: |

src/playbooks/deploy-proxy/metadata.obsah.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ variables:
1515
foreman_name:
1616
parameter: --foreman-fqdn
1717
help: FQDN of the Foreman server this proxy connects to.
18-
foreman_proxy_oauth_consumer_key:
19-
parameter: --oauth-consumer-key
20-
help: OAuth key to be used for communication with Foreman.
21-
foreman_proxy_oauth_consumer_secret:
22-
parameter: --oauth-consumer-secret
23-
help: OAuth secret to be used for communication with Foreman.
2418

2519
include:
2620
- _flavor_features
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
help: |
3+
Prepare a proxy host for deployment.
4+
5+
variables:
6+
hostname:
7+
parameter: hostname
8+
help: FQDN of the proxy host to prepare.
9+
required: true
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: Read OAuth consumer key from file
3+
ansible.builtin.slurp:
4+
src: /root/foreman-oauth-consumer-key
5+
register: _oauth_key_file
6+
7+
- name: Set OAuth consumer key
8+
ansible.builtin.set_fact:
9+
foreman_proxy_oauth_consumer_key: "{{ _oauth_key_file.content | b64decode | trim }}"
10+
11+
- name: Read OAuth consumer secret from file
12+
ansible.builtin.slurp:
13+
src: /root/foreman-oauth-consumer-secret
14+
register: _oauth_secret_file
15+
16+
- name: Set OAuth consumer secret
17+
ansible.builtin.set_fact:
18+
foreman_proxy_oauth_consumer_secret: "{{ _oauth_secret_file.content | b64decode | trim }}"
19+

src/roles/pre_install/tasks/katello.yaml

Whitespace-only changes.

src/roles/pre_install/tasks/main.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
- name: Include flavor tasks
3+
ansible.builtin.include_tasks: "{{ flavor }}.yaml"
4+
25
- name: Deploy debug_tools
36
ansible.builtin.include_role:
47
name: debug_tools

0 commit comments

Comments
 (0)