Files
kayobe/playbooks/kayobe-base/post.yml
Will Szumski 2829bf89f7 CI: Test kayobe_control_host_become
This change adds support for the kayobe_control_host_become variable to
CI jobs. This variable will cause any uses of become on localhost to
fail. This allows us to test that the kayobe_control_host_become
configuration variable has successfully removed all uses of become.

I've enabled this on a subset of jobs to get good test coverage.

Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/949758
Change-Id: I6da98e055714f75112cf08ff8aa53dd84de2e425
2025-05-19 17:20:21 +01:00

46 lines
1.7 KiB
YAML

---
- hosts: primary
environment:
KAYOBE_CONFIG_SOURCE_PATH: "{{ kayobe_config_src_dir }}"
tasks:
# Checks become validator was correctly configured in pre.yml.
- block:
- name: Create a playbook to test become validator was configured
copy:
content: |
---
- hosts: localhost
tasks:
- name: Testing become fails
command: "true"
become: true
register: result
failed_when: '"CONTROL_HOST_BECOME_VIOLATION" not in result.module_stderr'
dest: /tmp/test-control-host-become.yml
- name: Check that that kayobe become validator was correctly configured
shell:
cmd: "{{ kayobe_src_dir }}/dev/playbook-run.sh /tmp/test-control-host-become.yml &> {{ logs_dir }}/ansible/kayobe-test-control-host-become"
executable: /bin/bash
failed_when: false
register: become_check_result
when: not kayobe_control_host_become | bool
- hosts: all
roles:
- role: kayobe-diagnostics
kayobe_diagnostics_phase: "post"
kayobe_diagnostics_log_dir: "/tmp/logs"
kayobe_diagnostics_config_dir: "{{ kayobe_config_src_dir }}"
kayobe_diagnostics_previous_config_dir: "{{ previous_kayobe_config_src_dir }}"
kayobe_diagnostics_executor_log_dir: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}"
- hosts: primary
tasks:
# Fail after logs have been posted
- name: Fail run if "Check that that kayobe become validator was correctly configured" failed
assert:
that: become_check_result.rc == 0
when: become_check_result is not skipped