Compare commits
5 Commits
0f8faf0a22
...
b84688f1d6
| Author | SHA1 | Date | |
|---|---|---|---|
| b84688f1d6 | |||
| b1d2294d63 | |||
| ac339b54c4 | |||
| cb46a6989f | |||
| 73ea7a177b |
@@ -2,12 +2,7 @@
|
|||||||
- name: Copy NetworkManager keyfile per interface
|
- name: Copy NetworkManager keyfile per interface
|
||||||
vars:
|
vars:
|
||||||
configuration_iface: "{{ item }}"
|
configuration_iface: "{{ item }}"
|
||||||
configuration_iface_name: >-
|
configuration_iface_name: "{{ item.name | default('') }}"
|
||||||
{{
|
|
||||||
item.name
|
|
||||||
if (item.name | default('') | string | length) > 0
|
|
||||||
else (configuration_detected_interfaces[idx] | default('eth' ~ idx))
|
|
||||||
}}
|
|
||||||
configuration_net_uuid: "{{ ('LAN-' ~ idx ~ '-' ~ hostname) | ansible.builtin.to_uuid }}"
|
configuration_net_uuid: "{{ ('LAN-' ~ idx ~ '-' ~ hostname) | ansible.builtin.to_uuid }}"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: network.j2
|
src: network.j2
|
||||||
|
|||||||
@@ -15,9 +15,12 @@
|
|||||||
validate: /usr/sbin/visudo --check --file=%s
|
validate: /usr/sbin/visudo --check --file=%s
|
||||||
|
|
||||||
- name: Deploy per-user sudoers rules
|
- name: Deploy per-user sudoers rules
|
||||||
when: item.sudo is defined and (item.sudo | string | length) > 0
|
when: item.sudo | default(false)
|
||||||
|
vars:
|
||||||
|
configuration_sudoers_rule: >-
|
||||||
|
{{ item.sudo if item.sudo is string else 'ALL=(ALL) NOPASSWD: ALL' }}
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: "{{ item.name }} {{ item.sudo }}\n"
|
content: "{{ item.name }} {{ configuration_sudoers_rule }}\n"
|
||||||
dest: "/mnt/etc/sudoers.d/{{ item.name }}"
|
dest: "/mnt/etc/sudoers.d/{{ item.name }}"
|
||||||
mode: "0440"
|
mode: "0440"
|
||||||
validate: /usr/sbin/visudo --check --file=%s
|
validate: /usr/sbin/visudo --check --file=%s
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
- name: Set root password
|
- name: Set root password
|
||||||
ansible.builtin.shell: >-
|
ansible.builtin.shell: >-
|
||||||
set -o pipefail &&
|
set -o pipefail &&
|
||||||
echo 'root:{{ system_cfg.root.password | password_hash("sha512") }}' | {{ chroot_command }} chpasswd -e
|
echo 'root:{{ system_cfg.root.password | password_hash("sha512") }}' | {{ chroot_command }} /usr/sbin/chpasswd -e
|
||||||
args:
|
args:
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
register: configuration_root_result
|
register: configuration_root_result
|
||||||
@@ -49,12 +49,12 @@
|
|||||||
|
|
||||||
- name: Add SSH public keys to authorized_keys
|
- name: Add SSH public keys to authorized_keys
|
||||||
vars:
|
vars:
|
||||||
_uid: "{{ 1000 + (system_cfg.users | map(attribute='name') | list).index(item.0.name) }}"
|
configuration_uid: "{{ 1000 + (system_cfg.users | map(attribute='name') | list).index(item.0.name) }}"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "/mnt/home/{{ item.0.name }}/.ssh/authorized_keys"
|
path: "/mnt/home/{{ item.0.name }}/.ssh/authorized_keys"
|
||||||
line: "{{ item.1 }}"
|
line: "{{ item.1 }}"
|
||||||
owner: "{{ _uid }}"
|
owner: "{{ configuration_uid }}"
|
||||||
group: "{{ _uid }}"
|
group: "{{ configuration_uid }}"
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
create: true
|
create: true
|
||||||
loop: "{{ system_cfg.users | subelements('keys', skip_missing=True) }}"
|
loop: "{{ system_cfg.users | subelements('keys', skip_missing=True) }}"
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
id=LAN-{{ idx }}
|
id=LAN-{{ idx }}
|
||||||
uuid={{ configuration_net_uuid }}
|
uuid={{ configuration_net_uuid }}
|
||||||
type=ethernet
|
type=ethernet
|
||||||
|
autoconnect-priority=10
|
||||||
|
{% if configuration_iface_name | length > 0 %}
|
||||||
interface-name={{ configuration_iface_name }}
|
interface-name={{ configuration_iface_name }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[ipv4]
|
[ipv4]
|
||||||
{% set iface = configuration_iface %}
|
{% set iface = configuration_iface %}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
if (system_raw.network.interfaces | default([]) | length > 0)
|
if (system_raw.network.interfaces | default([]) | length > 0)
|
||||||
else (
|
else (
|
||||||
[{
|
[{
|
||||||
'name': 'eth0',
|
'name': '',
|
||||||
'bridge': system_raw.network.bridge | default('') | string,
|
'bridge': system_raw.network.bridge | default('') | string,
|
||||||
'vlan': system_raw.network.vlan | default('') | string,
|
'vlan': system_raw.network.vlan | default('') | string,
|
||||||
'ip': system_raw.network.ip | default('') | string,
|
'ip': system_raw.network.ip | default('') | string,
|
||||||
|
|||||||
@@ -10,3 +10,30 @@
|
|||||||
|
|
||||||
- name: Normalize disk configuration
|
- name: Normalize disk configuration
|
||||||
ansible.builtin.include_tasks: _normalize_disks.yml
|
ansible.builtin.include_tasks: _normalize_disks.yml
|
||||||
|
|
||||||
|
- name: Check if pre-computed system_cfg needs enrichment
|
||||||
|
when: system_cfg is defined
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
_bootstrap_needs_enrichment: "{{ hostname is not defined }}"
|
||||||
|
|
||||||
|
- name: Merge pre-computed system_cfg with bootstrap system_defaults
|
||||||
|
when:
|
||||||
|
- system_cfg is defined
|
||||||
|
- _bootstrap_needs_enrichment | default(false) | bool
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
system_cfg: "{{ system_defaults | combine(system | default({}), recursive=True) | combine(system_cfg, recursive=True) }}"
|
||||||
|
|
||||||
|
- name: Derive convenience facts from pre-computed system_cfg
|
||||||
|
when:
|
||||||
|
- system_cfg is defined
|
||||||
|
- _bootstrap_needs_enrichment | default(false) | bool
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
hostname: "{{ system_cfg.name | default(inventory_hostname) }}"
|
||||||
|
os: "{{ system_cfg.os | default('') }}"
|
||||||
|
os_version: "{{ system_cfg.version | default('') | string }}"
|
||||||
|
|
||||||
|
- name: Normalize disk configuration (pre-computed system_cfg)
|
||||||
|
when:
|
||||||
|
- system_cfg is defined
|
||||||
|
- install_drive is not defined
|
||||||
|
ansible.builtin.include_tasks: _normalize_disks.yml
|
||||||
|
|||||||
Reference in New Issue
Block a user