2023-07-19 12:06:35 +00:00
|
|
|
- name: Set hostname
|
|
|
|
hostname:
|
|
|
|
name: '{{ inventory_hostname }}'
|
2023-04-19 17:15:44 +00:00
|
|
|
|
|
|
|
- name: Set up resolv.conf
|
|
|
|
template:
|
|
|
|
dest: /etc/resolv.conf
|
|
|
|
src: resolv.conf.j2
|
|
|
|
mode: 0644
|
|
|
|
|
2023-11-18 18:44:00 +00:00
|
|
|
- name: Set up debian repositories
|
|
|
|
template:
|
|
|
|
dest: /etc/apt/sources.list
|
|
|
|
src: sources.list.j2
|
|
|
|
mode: 0644
|
|
|
|
notify: update package cache
|
|
|
|
when: debian_release is defined
|
|
|
|
|
2023-04-19 17:15:44 +00:00
|
|
|
- name: Install essential packages
|
2024-05-18 16:35:41 +00:00
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- git
|
|
|
|
- ifupdown2
|
|
|
|
- rsync
|
|
|
|
- vim
|
|
|
|
- tmux
|
2023-04-19 17:15:44 +00:00
|
|
|
|
2024-05-18 16:35:41 +00:00
|
|
|
- name: Add rules to rename network interfaces
|
|
|
|
template:
|
|
|
|
dest: /etc/udev/rules.d/10-network.rules
|
|
|
|
src: 10-network.rules.j2
|
|
|
|
mode: 0644
|
|
|
|
notify: reboot
|
|
|
|
|
|
|
|
# we don’t want to template this file because it gets overwritten by proxmox
|
|
|
|
# so just try removing anything that messes with our definitions in interfaces.d
|
|
|
|
- name: Remove interface definitions added by installer
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/network/interfaces
|
|
|
|
regexp: '^iface [^ ]* inet'
|
|
|
|
state: absent
|
|
|
|
notify: reload interfaces
|
2023-04-19 17:15:44 +00:00
|
|
|
|
2024-05-18 16:35:41 +00:00
|
|
|
- name: Include interfaces.d definitions
|
2023-04-19 17:15:44 +00:00
|
|
|
lineinfile:
|
2024-05-18 16:35:41 +00:00
|
|
|
path: /etc/network/interfaces
|
|
|
|
line: 'source /etc/network/interfaces.d/*'
|
|
|
|
notify: reload interfaces
|
2023-04-19 17:15:44 +00:00
|
|
|
|
2024-05-18 16:35:41 +00:00
|
|
|
- name: Set up interfaces
|
2023-04-19 17:15:44 +00:00
|
|
|
template:
|
2024-05-18 16:35:41 +00:00
|
|
|
dest: /etc/network/interfaces.d/ansible.intf
|
|
|
|
src: ansible.intf.j2
|
2023-04-19 17:15:44 +00:00
|
|
|
mode: 0644
|
2024-05-18 16:35:41 +00:00
|
|
|
notify: reload interfaces
|
|
|
|
|
|
|
|
- name: Run SSH instance in management VRF
|
|
|
|
when: interfaces | selectattr('vrf') | selectattr('vrf.name', '==', 'mgmt')
|
|
|
|
block:
|
|
|
|
- name: Configure SSH instance in management VRF
|
|
|
|
copy:
|
|
|
|
dest: /etc/ssh/
|
|
|
|
src: sshd_config.mgmt
|
|
|
|
mode: 0644
|
|
|
|
notify: reboot
|
|
|
|
|
|
|
|
- name: Set up a SSH instance in management VRF
|
|
|
|
copy:
|
|
|
|
dest: /etc/systemd/system/
|
|
|
|
src: sshd@mgmt.service
|
|
|
|
mode: 0644
|
|
|
|
notify: reboot
|
2023-04-19 17:15:44 +00:00
|
|
|
|
2024-05-18 16:35:41 +00:00
|
|
|
- name: Enable management SSH
|
|
|
|
service:
|
|
|
|
name: sshd@mgmt
|
|
|
|
enabled: yes
|
|
|
|
notify: reboot
|
|
|
|
|
|
|
|
- meta: flush_handlers
|