Compare commits

...

2 commits

Author SHA1 Message Date
Timotej Lazar ec4dcd4ffd frr: don’t use undefined variable 2024-08-28 12:43:17 +02:00
Timotej Lazar 211d4bdb9a Deconsolidate network setup for proxmox and debian roles
They are just different enough to be annoying.
2024-08-28 12:43:14 +02:00
11 changed files with 105 additions and 20 deletions

View file

@ -29,7 +29,7 @@ router bgp {{ asn.asn }}
neighbor fabric route-map local out neighbor fabric route-map local out
exit-address-family exit-address-family
{% if cluster.custom_fields and cluster.custom_fields.vlans %} {% if cluster is defined and cluster.custom_fields and cluster.custom_fields.vlans %}
address-family l2vpn evpn address-family l2vpn evpn
neighbor fabric activate neighbor fabric activate
neighbor fabric route-map local out neighbor fabric route-map local out

View file

@ -1,3 +1,12 @@
- name: reboot
reboot:
when: "'handler' not in ansible_skip_tags"
- name: reload interfaces - name: reload interfaces
command: ifreload -a command: ifreload -a
when: "'handler' not in ansible_skip_tags" when: "'handler' not in ansible_skip_tags"
- name: update package cache
package:
update_cache: yes
when: "'handler' not in ansible_skip_tags"

View file

@ -1,41 +1,55 @@
# choose a node for tasks that should only run on (any) one node, e.g. when writing to /etc/pve # choose a node for tasks that should only run on (any) one node, e.g. when writing to /etc/pve
- name: Select the primary node - name: Select the primary node
set_fact: set_fact:
is_primary: '{{ inventory_hostname == (nodes | map(attribute="inventory_hostname") | sort | first) }}' is_primary: '{{ nodes is defined and inventory_hostname == (nodes | map(attribute="inventory_hostname") | sort | first) }}'
- name: Set hostname
hostname:
name: '{{ inventory_hostname }}'
- name: Set up hosts file
template:
dest: /etc/hosts
src: hosts.j2
- name: Set up resolv.conf
template:
dest: /etc/resolv.conf
src: resolv.conf.j2
mode: 0644
- include_tasks: network.yml
- name: Disable enterprise repositories - name: Disable enterprise repositories
apt_repository: apt_repository:
repo: '{{ item }}' repo: '{{ item }}'
state: absent state: absent
update_cache: '{{ ansible_loop.last }}' update_cache: no
loop: loop:
- 'deb https://enterprise.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-enterprise' - 'deb https://enterprise.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-enterprise'
- 'deb https://enterprise.proxmox.com/debian/ceph-quincy {{ ansible_distribution_release }} enterprise' - 'deb https://enterprise.proxmox.com/debian/ceph-quincy {{ ansible_distribution_release }} enterprise'
loop_control: notify: update package cache
extended: true
- name: Enable no-subscription repository - name: Enable no-subscription repository
apt_repository: apt_repository:
repo: 'deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription' repo: 'deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription'
update_cache: no
notify: update package cache
- meta: flush_handlers
- name: Install essential packages
package:
name:
- git
- vim
- tmux
- name: Set up sysctls - name: Set up sysctls
copy: copy:
dest: /etc/sysctl.d/local.conf dest: /etc/sysctl.d/local.conf
src: sysctl.conf src: sysctl.conf
- name: Set VXLAN local tunnel IP
template:
dest: /etc/network/interfaces.d/loopback.intf
src: loopback.intf.j2
notify: reload interfaces
- name: Set up bridges
template:
dest: /etc/network/interfaces
src: interfaces.j2
mode: 0644
notify: reload interfaces
- include_tasks: firewall.yml - include_tasks: firewall.yml
- include_tasks: user.yml - include_tasks: user.yml

View file

@ -0,0 +1,51 @@
- 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 bridges
template:
dest: /etc/network/interfaces
src: interfaces.j2
mode: 0644
notify: reload interfaces
- name: Set VXLAN local tunnel IP
template:
dest: /etc/network/interfaces.d/loopback.intf
src: loopback.intf.j2
notify: reload interfaces
- name: Set up physical interfaces
template:
dest: /etc/network/interfaces.d/ansible.intf
src: ansible.intf.j2
mode: 0644
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
- name: Enable management SSH
service:
name: sshd@mgmt
enabled: yes
notify: reboot
- meta: flush_handlers

View file

@ -0,0 +1,12 @@
127.0.0.1 localhost.localdomain localhost
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
{% for address in interfaces | selectattr('name', '==', 'lo') | map(attribute='ip_addresses') | first %}
{{ address.address | ipaddr('address') }} {{ address.dns_name }} {{ inventory_hostname }}
{% endfor %}

View file

@ -23,9 +23,8 @@
- hosts: pve-rc-*, pve-lab-* - hosts: pve-rc-*, pve-lab-*
roles: roles:
- debian
- frr
- proxmox - proxmox
- frr
- hosts: doku - hosts: doku
roles: roles: