debian: get inventory data from netbox
Set standardized interface names (mgmt0… for L2 management interfaces and lan0… for L3 data interfaces speaking BGP). ASN is stored as a custom field in netbox but that might change.
This commit is contained in:
parent
2330edf479
commit
63ab087645
7 changed files with 69 additions and 48 deletions
|
@ -1,13 +1,4 @@
|
|||
- name: Set hostname
|
||||
hostname:
|
||||
name: '{{ inventory_hostname }}'
|
||||
|
||||
- name: Set up management interface
|
||||
template:
|
||||
dest: /etc/network/interfaces
|
||||
src: interfaces.j2
|
||||
mode: 0644
|
||||
notify: reboot
|
||||
- include_tasks: mgmt.yml
|
||||
|
||||
- name: Set up loopback interface
|
||||
template:
|
||||
|
@ -23,32 +14,9 @@
|
|||
mode: 0644
|
||||
notify: reload interfaces
|
||||
|
||||
- name: Install ifupdown2
|
||||
package: name=ifupdown2
|
||||
notify: reboot
|
||||
|
||||
- name: Create override directory for ssh service
|
||||
file:
|
||||
path: /etc/systemd/system/ssh.service.d
|
||||
state: directory
|
||||
|
||||
- name: Run ssh in mgmt VRF
|
||||
copy:
|
||||
dest: /etc/systemd/system/ssh.service.d/override.conf
|
||||
src: ssh.service-override.conf
|
||||
notify: reboot
|
||||
|
||||
# With PAM enabled, login shell would run in default VRF instead of mgmt.
|
||||
- name: Disable PAM for ssh
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^UsePAM .*yes'
|
||||
state: absent
|
||||
notify: reboot
|
||||
|
||||
# Reboot here if anything changed to ensure the new VRF is up and sshd
|
||||
# listens there.
|
||||
- meta: flush_handlers
|
||||
- name: Set hostname
|
||||
hostname:
|
||||
name: '{{ inventory_hostname }}'
|
||||
|
||||
- name: Set up resolv.conf
|
||||
template:
|
||||
|
|
39
roles/debian/tasks/mgmt.yml
Normal file
39
roles/debian/tasks/mgmt.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
- 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
|
||||
|
||||
- name: Set up management interface
|
||||
template:
|
||||
dest: /etc/network/interfaces
|
||||
src: interfaces.j2
|
||||
mode: 0644
|
||||
notify: reboot
|
||||
|
||||
- name: Install ifupdown2
|
||||
package: name=ifupdown2
|
||||
notify: reboot
|
||||
|
||||
- name: Create override directory for ssh service
|
||||
file:
|
||||
path: /etc/systemd/system/ssh.service.d
|
||||
state: directory
|
||||
|
||||
- name: Set up ssh to run in mgmt VRF
|
||||
copy:
|
||||
dest: /etc/systemd/system/ssh.service.d/override.conf
|
||||
src: ssh.service-override.conf
|
||||
notify: reboot
|
||||
|
||||
# With PAM enabled, login shell would run in default VRF instead of mgmt.
|
||||
- name: Disable PAM for ssh
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^UsePAM .*yes'
|
||||
state: absent
|
||||
notify: reboot
|
||||
|
||||
- meta: flush_handlers
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue