ansible_public/pioniers/playbooks/config/config_network.yaml

66 lines
1.8 KiB
YAML
Raw Normal View History

2022-06-14 18:53:16 +02:00
---
- hosts: '{{ variable_host | default("pioniers") }}'
gather_facts: no
become: yes
tasks:
- name: Recursively find /tmp files older than 2 days
find:
paths: /etc/netplan/00-installer-config-wifi.yaml
register: config_found
changed_when: config_found["matched"] == 0
- debug:
msg: "File doesn't exists"
when: config_found is changed
- name: Check wifi-configuration
lineinfile:
path: /etc/netplan/00-installer-config-wifi.yaml
regexp: '^LabL15_24'
state: absent
check_mode: yes
register: config_exists
when: config_found is succeeded
- name: Remove old wifi config
when:
- config_exists is changed
- config_found is succeeded
file:
path: /etc/netplan/00-installer-config-wifi.yaml
state: absent
- name: Create wifi file configuration
when:
# - config_exists is changed
- config_found is changed
file:
path: /etc/netplan/00-installer-config-wifi.yaml
state: touch
- name: Insert wifi-configuration
when:
- config_exists is changed
- config_found is succeeded
blockinfile:
path: /etc/netplan/00-installer-config-wifi.yaml
marker_begin: "Wifi configuration for pioniers ~Jakub Delicat"
marker_end: ""
block: |
# This is the network config written by 'subiquity'
network:
version: 2
wifis:
wlp1s0:
optional: true
access-points:
"LabL15_24":
password: "{{wifi_pass}}"
dhcp4: true