Skip to content

Commit 9002c4b

Browse files
committed
guestfs: provide console.log sane permission
We want to have user level permissions on the console.log for two reasons: - Leveraging the console as a backup in case the systemd remote journal files are not present - CI - we want to upload these as artifacts This leverages the new bringup_guestfs role, and we can use this after the script, so we can also grow the role with tags of tasks to run at the end as part of the guestfs bring up process. Signed-off-by: Luis Chamberlain <[email protected]>
1 parent f0ceee4 commit 9002c4b

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

playbooks/roles/bringup_guestfs/tasks/main.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,41 @@
112112
- 'libvirt_uri_system|bool'
113113
- libvirt_default_net.rc != 0
114114
tags: [ 'network' ]
115+
116+
- name: Get the actual user who invoked Ansible
117+
command: whoami
118+
register: reg_user
119+
changed_when: false
120+
when:
121+
- 'libvirt_uri_system|bool'
122+
tags: ['console-permissions']
123+
124+
- name: Look for console.log files in guestfs subdirectories to check for CI enablement
125+
become: yes
126+
become_flags: 'su - -c'
127+
become_method: sudo
128+
find:
129+
paths: "{{ topdir_path }}/guestfs"
130+
patterns: "console.log"
131+
file_type: file
132+
recurse: yes
133+
register: console_log_files
134+
when:
135+
- 'libvirt_uri_system|bool'
136+
tags: ['console-permissions']
137+
138+
- name: Ensure console.log files are owned by the main user for CI monitoring
139+
become: yes
140+
become_flags: 'su - -c'
141+
become_method: sudo
142+
file:
143+
path: "{{ item.path }}"
144+
owner: "{{ reg_user.stdout }}"
145+
group: "{{ reg_user.stdout }}"
146+
loop: "{{ console_log_files.files }}"
147+
loop_control:
148+
label: "{{ item.path | regex_replace('^.*guestfs/', 'guestfs/') }}"
149+
when:
150+
- 'libvirt_uri_system|bool'
151+
- console_log_files.matched > 0
152+
tags: ['console-permissions']

scripts/guestfs.Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ bringup_guestfs: $(GUESTFS_BRINGUP_DEPS)
8080
--extra-vars=@./extra_vars.yaml \
8181
--tags config-check,network
8282
$(Q)$(TOPDIR)/scripts/bringup_guestfs.sh
83+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
84+
--inventory localhost, \
85+
playbooks/bringup_guestfs.yml \
86+
-e 'ansible_python_interpreter=/usr/bin/python3' \
87+
--extra-vars=@./extra_vars.yaml \
88+
--tags console-permissions
8389
PHONY += bringup_guestfs
8490

8591
destroy_guestfs:

0 commit comments

Comments
 (0)