Skip to content

Commit

Permalink
Move fact capture to common. (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmcutter authored Jul 11, 2024
1 parent 700a2e5 commit 5e9aac2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 42 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/move_fact_capture_to_common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Move fact capture from analysis to ensure that facts are representative of the system immediately before upgrade.
42 changes: 0 additions & 42 deletions roles/analysis/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,6 @@
vars:
job_name: RIPU preupgrade analysis

- name: /etc/ansible/facts.d directory exists
ansible.builtin.file:
path: /etc/ansible/facts.d
state: directory
mode: "0755"
owner: root
group: root

- name: Capture current ansible_facts for validation after upgrade
ansible.builtin.copy:
content: "{{ ansible_facts | ansible.builtin.combine({'ansible_local': {}}) }}"
dest: /etc/ansible/facts.d/pre_ripu.fact
mode: "0644"
owner: root
group: root

- name: Capture a list of non-rhel versioned packages
ansible.builtin.shell:
cmd: >-
set -o pipefail;
export PATH={{ os_path }};
rpm -qa | grep -ve '[\.|+]el{{ ansible_distribution_major_version }}' |
grep -vE '^(gpg-pubkey|libmodulemd|katello-ca-consumer)' |
sort
register: unsigned_packages_pre
changed_when: false
failed_when:
- unsigned_packages_pre.rc != 0
- unsigned_packages_pre.stderr != ""

- name: Create fact with the non-rhel versioned packages list
ansible.builtin.set_fact:
non_rhel_packages: "{{ unsigned_packages_pre.stdout_lines }}"

- name: Capture the list of non-rhel versioned packages in a separate fact file
ansible.builtin.copy:
content: "{{ non_rhel_packages }}"
dest: /etc/ansible/facts.d/non_rhel_packages.fact
mode: "0644"
owner: root
group: root

- name: Include tasks for preupg assistant analysis
ansible.builtin.include_tasks: analysis-preupg.yml
when: ansible_distribution_major_version|int == 6
Expand Down
43 changes: 43 additions & 0 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,47 @@
mode: "0644"
notify:
- Archive log file

- name: /etc/ansible/facts.d directory exists
ansible.builtin.file:
path: /etc/ansible/facts.d
state: directory
mode: "0755"
owner: root
group: root

- name: Capture current ansible_facts for validation after upgrade
ansible.builtin.copy:
content: "{{ ansible_facts | ansible.builtin.combine({'ansible_local': {}}) }}"
dest: /etc/ansible/facts.d/pre_ripu.fact
mode: "0644"
owner: root
group: root

- name: Capture a list of non-rhel versioned packages
ansible.builtin.shell:
cmd: >-
set -o pipefail;
export PATH={{ os_path }};
rpm -qa | grep -ve '[\.|+]el{{ ansible_distribution_major_version }}' |
grep -vE '^(gpg-pubkey|libmodulemd|katello-ca-consumer)' |
sort
register: unsigned_packages_pre
changed_when: false
failed_when:
- unsigned_packages_pre.rc != 0
- unsigned_packages_pre.stderr != ""

- name: Create fact with the non-rhel versioned packages list
ansible.builtin.set_fact:
non_rhel_packages: "{{ unsigned_packages_pre.stdout_lines }}"

- name: Capture the list of non-rhel versioned packages in a separate fact file
ansible.builtin.copy:
content: "{{ non_rhel_packages }}"
dest: /etc/ansible/facts.d/non_rhel_packages.fact
mode: "0644"
owner: root
group: root

...

0 comments on commit 5e9aac2

Please sign in to comment.