Skip to content

Commit 87457c4

Browse files
Merge pull request #5337 from sjug/ansible_updates
USHIFT-5984: Rollup of Ansible script updates as of MicroShift 4.19
2 parents ba1f75b + ac2d048 commit 87457c4

File tree

14 files changed

+1872
-180
lines changed

14 files changed

+1872
-180
lines changed
Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
11
---
22
# add-kubelet-logging tasks
33

4-
- name: check to ensure promdir target exists
4+
- name: Check to ensure promdir target exists
55
ansible.builtin.stat:
66
path: "{{ prometheus_dir }}"
77
register: promdir
88

9-
- name: check if the file exists
9+
- name: Check if the file exists
1010
ansible.builtin.stat:
1111
path: "{{ sa_token_file }}"
1212
register: token_file
1313

14-
- block:
15-
- name: load sa-token file from localhost
16-
ansible.builtin.slurp:
17-
src: "{{ sa_token_file }}"
18-
register: bearer_token_slurp
19-
delegate_to: localhost
14+
- name: Deal with metrics service account token file
15+
when: token_file.stat.exists
16+
block:
17+
- name: Load sa-token file from localhost
18+
ansible.builtin.slurp:
19+
src: "{{ sa_token_file }}"
20+
register: bearer_token_slurp
21+
delegate_to: localhost
2022

21-
- name: decode bearer token
22-
set_fact:
23-
bearer_token: "{{ bearer_token_slurp.content | b64decode }}"
23+
- name: Decode bearer token
24+
ansible.builtin.set_fact:
25+
bearer_token: "{{ bearer_token_slurp.content | b64decode }}"
2426

25-
- name: create metrics service account token file in prometheus folder
26-
ansible.builtin.copy:
27-
content: "{{ bearer_token }}"
28-
dest: "{{ kubelet_auth_token_file }}"
29-
when: promdir.stat.exists
27+
- name: Create metrics service account token file in prometheus folder
28+
ansible.builtin.copy:
29+
content: "{{ bearer_token }}"
30+
dest: "{{ kubelet_auth_token_file }}"
31+
mode: '0644'
32+
when: promdir.stat.exists
3033

31-
- name: remove the sa-token file
32-
ansible.builtin.file:
33-
path: "{{ sa_token_file }}"
34-
state: absent
35-
when: token_file.stat.exists
34+
- name: Remove the sa-token file
35+
ansible.builtin.file:
36+
path: "{{ sa_token_file }}"
37+
state: absent
3638

37-
- name: append kubelet scrape config target to prometheus config
39+
- name: Append kubelet scrape config target to prometheus config
3840
ansible.builtin.blockinfile:
3941
path: "{{ prometheus_config }}"
4042
block: |
4143
# kubelet targets
42-
- job_name: kubelet
44+
{% for host in groups['microshift'] %}
45+
- job_name: kubelet-{{ host }}
4346
scheme: https
4447
authorization:
4548
credentials_file: "{{ kubelet_auth_token_file }}"
4649
tls_config:
4750
insecure_skip_verify: true
4851
static_configs:
4952
- targets:
50-
- microshift-dev:10250
53+
- {{ hostvars[host].ansible_host }}:10250
5154
52-
- job_name: kubelet cadvisor
55+
- job_name: kubelet-{{ host }}-cadvisor
5356
scheme: https
5457
authorization:
5558
credentials_file: "{{ kubelet_auth_token_file }}"
@@ -58,9 +61,10 @@
5861
metrics_path: /metrics/cadvisor
5962
static_configs:
6063
- targets:
61-
- microshift-dev:10250
64+
- {{ hostvars[host].ansible_host }}:10250
65+
{% endfor %}
6266
63-
- name: restart prometheus to pick up new target
67+
- name: Restart prometheus to pick up new target
6468
ansible.builtin.systemd:
6569
state: restarted
6670
name: prometheus

ansible/roles/common/tasks/boot.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
---
22
# common microshift boot start time script
33

4+
# Include shared microshift version configuration
5+
- name: Include shared microshift version configuration
6+
include_vars:
7+
file: "{{ playbook_dir }}/vars/microshift_versions.yml"
8+
49
- block:
510
- name: find microshift cleanup script
611
ansible.builtin.find:
@@ -16,13 +21,13 @@
1621
microshift_cleanup_bin: "{{ find_cleanup.files[0].path if find_cleanup.files }}"
1722

1823
- name: cleanup microshift data
19-
become: yes
24+
become: true
2025
ansible.builtin.shell: echo 1 | {{ microshift_cleanup_bin }} --all
2126
when: cleanup_microshift | default('false') | bool
2227

2328
- block:
2429
- name: reboot machine
25-
become: yes
30+
become: true
2631
ansible.builtin.reboot:
2732
reboot_timeout: 600
2833

@@ -31,9 +36,26 @@
3136
seconds: 60
3237
when: reboot | default('false') | bool
3338

39+
- name: Extract major version for pod counts
40+
set_fact:
41+
microshift_major_version: "{{ microshift_version.split('.')[:2] | join('.') }}"
42+
43+
- name: Validate that version exists in config
44+
fail:
45+
msg: "Error: MicroShift version {{ microshift_major_version }} not found in microshift_versions dictionary. Please update the defaults/main.yml file."
46+
when: microshift_major_version not in microshift_versions
47+
48+
- name: Set expected pod counts
49+
set_fact:
50+
expected_pods: "{{ microshift_versions[microshift_major_version].expected_pods }}"
51+
all_pods: "{{ microshift_versions[microshift_major_version].all_pods }}"
52+
3453
- name: run the microshift boot script
3554
ansible.builtin.script:
36-
cmd: ready.sh
55+
cmd: >
56+
ready.sh
57+
{{ expected_pods }}
58+
{{ all_pods }}
3759
register: script_output
3860

3961
- name: display script output

ansible/roles/configure-firewall/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ firewall_ports:
2727
firewall_trusted_cidr:
2828
- 10.42.0.0/16
2929
- 169.254.169.1/32
30+
- fd01::/48
3031

ansible/roles/install-logging/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ logging_services:
1212
grafana_setup: false
1313
grafana_username: admin
1414
grafana_password: admin
15+
grafana_host_address: "192.168.1.100"
1516
grafana_port: 3000
1617

1718
prometheus_port: 9091

0 commit comments

Comments
 (0)