resolvconf
This commit is contained in:
parent
7f4ac7485b
commit
b8224b7a6a
26
inventory
26
inventory
@ -1,22 +1,24 @@
|
||||
[nodes]
|
||||
192.168.50.1
|
||||
192.168.50.2
|
||||
192.168.50.3
|
||||
# 192.168.50.11
|
||||
# 192.168.50.12
|
||||
# 192.168.50.13
|
||||
# masters
|
||||
192.168.50.41
|
||||
192.168.50.42
|
||||
192.168.50.43
|
||||
# workers
|
||||
# 192.168.50.44
|
||||
# 192.168.50.45
|
||||
# 192.168.50.46
|
||||
|
||||
[master-primary]
|
||||
192.168.50.1
|
||||
192.168.50.41
|
||||
|
||||
# do one at a time
|
||||
# the k3s service restarts
|
||||
# on the primary when a node joins
|
||||
[master-secondary]
|
||||
192.168.50.2
|
||||
192.168.50.3
|
||||
192.168.50.42
|
||||
192.168.50.43
|
||||
|
||||
[workers]
|
||||
# 192.168.50.11
|
||||
# 192.168.50.12
|
||||
# 192.168.50.13
|
||||
# 192.168.50.44
|
||||
# 192.168.50.45
|
||||
# 192.168.50.46
|
||||
|
35
roles/nfs-storage/tasks/main.yml
Normal file
35
roles/nfs-storage/tasks/main.yml
Normal file
@ -0,0 +1,35 @@
|
||||
- name: Install packages
|
||||
ansible.builtin.apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
install_recommends: false
|
||||
loop: "nfs-kernel-server rpcbind"
|
||||
|
||||
- name: Check the disk for existing partitions
|
||||
ansible.builtin.stat:
|
||||
path: "{{ storage_disk }}1"
|
||||
register: partition_exists
|
||||
|
||||
- name: Format disk
|
||||
community.general.filesystem:
|
||||
fstype: "{{ fs_type }}"
|
||||
dev: "{{ storage_disk }}"
|
||||
when: not partition_exists
|
||||
|
||||
- name: Create mount
|
||||
ansible.builtin.template:
|
||||
src: etc-systemd-system-mnt-storage.mount.j2
|
||||
dest: "/etc/systemd/system/mnt-{{ mount_path }}.mount"
|
||||
mode: "0644"
|
||||
|
||||
- name: Enable mount
|
||||
ansible.builtin.systemd_service:
|
||||
name: "mnt-{{ mount_path }}.mount"
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Setup nfs-server
|
||||
ansible.builtin.template:
|
||||
src: etc-exports.j2
|
||||
dest: /etc/exports
|
||||
mode: "0644"
|
1
roles/nfs-storage/templates/etc-exports.j2
Normal file
1
roles/nfs-storage/templates/etc-exports.j2
Normal file
@ -0,0 +1 @@
|
||||
/mnt/cluster rw,no_root_squash
|
@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=mount {{ storage_disk }} at {{ mount_path }}
|
||||
|
||||
[Mount]
|
||||
Where={{ mount_path }}
|
||||
What={{ storage_disk }}1
|
||||
Type={{ fs_type }}
|
@ -1,9 +1,6 @@
|
||||
packages:
|
||||
- nfs-common
|
||||
- curl
|
||||
- systemd-resolved # needs to be the last one
|
||||
# breaks dns resolution until
|
||||
# systemd-networkd is configured
|
||||
|
||||
# hostsnames:
|
||||
# - ip: x.x.x.x
|
||||
@ -13,6 +10,6 @@ hostnames: []
|
||||
|
||||
interface_name: lan0
|
||||
gateway: "192.168.50.254"
|
||||
dns_servers:
|
||||
nameservers:
|
||||
- "192.168.11.1"
|
||||
- "1.1.1.1"
|
||||
|
@ -6,7 +6,7 @@
|
||||
cmd: >
|
||||
update-initramfs -k all -u
|
||||
|
||||
- name: Warn user to reboot
|
||||
ansible.builtin.set_fact:
|
||||
user_notify: Reboot the machine to use the new name for primary interface!
|
||||
when: systemd_networkd_ifname is changed
|
||||
- name: Reboot
|
||||
listen:
|
||||
- reboot
|
||||
ansible.builtin.reboot:
|
||||
|
@ -1,25 +1,32 @@
|
||||
- name: Check if default interface is configured
|
||||
ansible.builtin.set_fact:
|
||||
interface_configured: "{{ interface_name in ansible_interfaces }}"
|
||||
|
||||
- name: Configure default interface name
|
||||
ansible.builtin.template:
|
||||
src: etc-systemd-network-10-lan0.link.j2
|
||||
dest: /etc/systemd/network/10-lan0.link
|
||||
mode: "0644"
|
||||
register: systemd_networkd_ifname
|
||||
notify:
|
||||
- update initramfs
|
||||
- reboot
|
||||
when: not interface_configured
|
||||
|
||||
- name: Configure network for default interface
|
||||
ansible.builtin.template:
|
||||
src: etc-systemd-network-20-lan0.network.j2
|
||||
dest: /etc/systemd/network/20-lan0.network
|
||||
mode: "0644"
|
||||
notify: update initramfs
|
||||
when: not interface_configured
|
||||
|
||||
- name: Configure nameservers
|
||||
ansible.builtin.template:
|
||||
src: etc-resolv.conf.j2
|
||||
dest: /etc/resolv.conf
|
||||
mode: "0644"
|
||||
|
||||
- name: Enable systemd-networkd
|
||||
ansible.builtin.systemd_service:
|
||||
name: systemd-networkd
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
- name: Enable systemd-resolved
|
||||
ansible.builtin.systemd_service:
|
||||
name: systemd-resolved
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
3
roles/node/templates/etc-resolv.conf.j2
Normal file
3
roles/node/templates/etc-resolv.conf.j2
Normal file
@ -0,0 +1,3 @@
|
||||
{% for nameserver in nameservers %}
|
||||
nameserver {{ nameserver }}
|
||||
{% endfor %}
|
@ -4,6 +4,6 @@ Name={{ interface_name }}
|
||||
[Network]
|
||||
Address={{ ansible_default_ipv4.address|default(ansible_all_ipv4_addresses[0]) }}/24
|
||||
Gateway={{ gateway }}
|
||||
{% for dns in dns_servers %}
|
||||
DNS={{ dns }}
|
||||
{% for nameserver in nameservers %}
|
||||
DNS={{ nameserver }}
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user