Skip to content

Commit

Permalink
cleanup netplan files, cleanup journald
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxRink committed Jul 21, 2021
1 parent 0774bb5 commit 44ab490
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions images/capi/ansible/roles/sysprep/tasks/main.yml
Expand Up @@ -109,6 +109,24 @@
path: "{{ item.path }}"
loop: "{{ temp_files.files }}"

- name: Find netplan files
find:
depth: 1
file_type: any
paths:
- /lib/netplan
- /etc/netplan
- /run/netplan
pattern: '*.yaml'
register: netplan_files

- name: Delete netplan files
file:
state: absent
path: "{{ item.path }}"
loop: "{{ netplan_files.files }}"
when: netplan_files.files is defined and (netplan_files.files|length>0)

- name: Find SSH host keys
find:
path: /etc/ssh
Expand Down Expand Up @@ -167,3 +185,14 @@
loop:
- { path: /root/.bash_history }
- { path: "/home/{{ ansible_env.SUDO_USER }}/.bash_history" }

- name: Rotate journalctl to archive logs
shell:
cmd: |
journalctl --rotate
when: not ( ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 7 )

- name: Remove archived journalctl logs
shell:
cmd: |
journalctl -m --vacuum-time=1s

1 comment on commit 44ab490

@dimatha
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like deleting the default "/etc/netplan/01-netcfg.yaml" config on Ubuntu 18.04 ova results in machine not getting DHCP address on the first boot until you reboot it once more.

Please sign in to comment.