Skip to content

Commit 6ba812e

Browse files
author
Arvind Jangir
committed
prepare proxy before deployment
1 parent a365641 commit 6ba812e

7 files changed

Lines changed: 99 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,9 @@ 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 \

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
inventory_dir: "{{ inventory_dir }}"
35+
36+
- name: Transfer proxy certificate bundle and oauth credentials to proxy host
37+
hosts: proxy
38+
become: true
39+
vars_files:
40+
- "../../vars/foreman.yml"
41+
tasks:
42+
- name: Check SSH connectivity and authentication to proxy
43+
ansible.builtin.ping:
44+
45+
- name: Copy certificate bundle to proxy
46+
ansible.builtin.copy:
47+
src: "{{ obsah_state_path }}/{{ hostname }}.tar.gz"
48+
dest: "/tmp/{{ hostname }}.tar.gz"
49+
mode: "0600"
50+
owner: root
51+
group: root
52+
53+
- name: Copy OAuth consumer key to proxy
54+
ansible.builtin.copy:
55+
src: "{{ foreman_oauth_consumer_key_file }}"
56+
dest: "{{ obsah_state_path }}/foreman-oauth-consumer-key"
57+
mode: "0600"
58+
owner: root
59+
group: root
60+
61+
- name: Copy OAuth consumer secret to proxy
62+
ansible.builtin.copy:
63+
src: "{{ foreman_oauth_consumer_secret_file }}"
64+
dest: "{{ obsah_state_path }}/foreman-oauth-consumer-secret"
65+
mode: "0600"
66+
owner: root
67+
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: "{{ obsah_state_path }}/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: "{{ obsah_state_path }}/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)