Use the .yaml file extension for all YAML files
This commit is contained in:
parent
9d0697f0d0
commit
1bcb77961b
52 changed files with 1 additions and 1 deletions
8
playbooks/deploy_audio_pi.yaml
Normal file
8
playbooks/deploy_audio_pi.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- name: Configure audio.z9 as a bluetooth audio sink and AirPlay server
|
||||
become: true
|
||||
hosts: audio
|
||||
roles:
|
||||
- hifiberry
|
||||
- bluetooth_audio_sink
|
||||
- shairport_sync
|
||||
6
playbooks/deploy_automation.yaml
Normal file
6
playbooks/deploy_automation.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Deploy mosquitto MQTT broker on automation.z9
|
||||
become: true
|
||||
hosts: automation
|
||||
roles:
|
||||
- mosquitto
|
||||
39
playbooks/deploy_dokuwiki.yaml
Normal file
39
playbooks/deploy_dokuwiki.yaml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
- name: Configure wiki.z9 with dokuwiki
|
||||
become: true
|
||||
hosts: wiki
|
||||
roles:
|
||||
- nginx
|
||||
- cert
|
||||
tasks:
|
||||
# TODO: make this a role
|
||||
- name: Install php-fpm
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- php-fpm
|
||||
- php-xml
|
||||
- php-mbstring
|
||||
- php-zip
|
||||
- php-intl
|
||||
- php-gd
|
||||
diff: false
|
||||
- name: Make sure php-fpm is enabled
|
||||
ansible.builtin.systemd:
|
||||
service: php7.4-fpm.service
|
||||
enabled: true
|
||||
|
||||
# place dokuwiki zip into /var/www/dokuwiki manually!
|
||||
- name: Create www dir
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: /var/www
|
||||
state: directory
|
||||
owner: nginx
|
||||
group: nginx
|
||||
mode: "0755"
|
||||
- name: Custom php-fpm config
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
src: configs/wiki/php-fpm-dokuwiki.conf
|
||||
dest: /etc/php/7.4/fpm/pool.d/dokuwiki.conf
|
||||
mode: "0755"
|
||||
7
playbooks/deploy_esphome.yaml
Normal file
7
playbooks/deploy_esphome.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- name: Deploy esphome on esphome.z9
|
||||
become: true
|
||||
hosts: esphome
|
||||
roles:
|
||||
- esphome
|
||||
- nginx
|
||||
8
playbooks/deploy_light.yaml
Normal file
8
playbooks/deploy_light.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- name: Deploy ola and foobazdmx on light.z9
|
||||
become: true
|
||||
hosts: light
|
||||
roles:
|
||||
- ola
|
||||
- foobazdmx
|
||||
- nginx
|
||||
7
playbooks/deploy_zigbee2mqtt.yaml
Normal file
7
playbooks/deploy_zigbee2mqtt.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- name: Deploy zigbee2mqtt on zigbee2mqtt.z9
|
||||
become: true
|
||||
hosts: zigbee2mqtt
|
||||
roles:
|
||||
- zigbee2mqtt
|
||||
- nginx
|
||||
25
playbooks/roles/add_apt_repository/meta/argument_specs.yaml
Normal file
25
playbooks/roles/add_apt_repository/meta/argument_specs.yaml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
argument_specs:
|
||||
main:
|
||||
short_description: Add a 3rd party apt repository to the system
|
||||
options:
|
||||
add_apt_repository__https_repo:
|
||||
description: The repository URL uses HTTPS
|
||||
required: true
|
||||
type: bool
|
||||
add_apt_repository__keyring_url:
|
||||
description: URL to the repository's keyring
|
||||
required: false
|
||||
type: str
|
||||
add_apt_repository__keyring_path:
|
||||
description: Path where to store the keyring
|
||||
required: false
|
||||
type: str
|
||||
add_apt_repository__repo:
|
||||
description: The apt source line
|
||||
required: true
|
||||
type: str
|
||||
add_apt_repository__filename:
|
||||
description: Filename in /etc/apt/sources.list.d/
|
||||
required: true
|
||||
type: str
|
||||
25
playbooks/roles/add_apt_repository/tasks/main.yaml
Normal file
25
playbooks/roles/add_apt_repository/tasks/main.yaml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
- name: Check OS family
|
||||
ansible.builtin.fail:
|
||||
msg: "Can only add apt repositories on Debian-based systems!"
|
||||
when: ansible_facts.os_family != "Debian"
|
||||
- name: Install required apt packages for adding an apt repository
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- ca-certificates
|
||||
- gnupg
|
||||
- name: Install apt-transport-https if https repository
|
||||
ansible.builtin.apt:
|
||||
name: apt-transport-https
|
||||
when: add_apt_repository__https_repo
|
||||
- name: Add repository signing key to keychain
|
||||
when: add_apt_repository__keyring_url is defined and add_apt_repository__keyring_path is defined
|
||||
ansible.builtin.apt_key:
|
||||
url: "{{ add_apt_repository__keyring_url }}"
|
||||
keyring: "{{ add_apt_repository__keyring_path }}"
|
||||
state: present
|
||||
- name: Add repository and update cache
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "{{ add_apt_repository__repo }}"
|
||||
filename: "{{ add_apt_repository__filename }}"
|
||||
update_cache: true
|
||||
14
playbooks/roles/bluetooth_audio_sink/handlers/main.yaml
Normal file
14
playbooks/roles/bluetooth_audio_sink/handlers/main.yaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
- name: Restart bluetooth service
|
||||
ansible.builtin.systemd:
|
||||
service: bluetooth.service
|
||||
state: restarted
|
||||
- name: Restart speaker-agent service
|
||||
become_user: audiosink
|
||||
ansible.builtin.systemd:
|
||||
service: speaker-agent.service
|
||||
state: restarted
|
||||
scope: user
|
||||
daemon_reload: true
|
||||
- name: Reboot host
|
||||
ansible.builtin.reboot:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
argument_specs:
|
||||
main:
|
||||
options:
|
||||
bluetooth_audio_sink__name:
|
||||
description: Name the bluetooth device should have
|
||||
type: str
|
||||
required: true
|
||||
8
playbooks/roles/bluetooth_audio_sink/meta/main.yaml
Normal file
8
playbooks/roles/bluetooth_audio_sink/meta/main.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
dependencies:
|
||||
- role: distribution_check
|
||||
vars:
|
||||
distribution_check__supported_distributions:
|
||||
- name: Debian
|
||||
versions:
|
||||
- "11"
|
||||
141
playbooks/roles/bluetooth_audio_sink/tasks/main.yaml
Normal file
141
playbooks/roles/bluetooth_audio_sink/tasks/main.yaml
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
---
|
||||
- name: Ensure acl is installed
|
||||
ansible.builtin.apt:
|
||||
name: acl
|
||||
- name: Ensure machine-info file is deployed
|
||||
ansible.builtin.template:
|
||||
src: machine-info.j2
|
||||
dest: /etc/machine-info
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: Restart bluetooth service
|
||||
- name: Ensure bluetooth config is deployed
|
||||
ansible.builtin.template:
|
||||
src: main.conf.j2
|
||||
dest: /etc/bluetooth/main.conf
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: Restart bluetooth service
|
||||
- name: Ensure bluetooth service is enabled and started
|
||||
ansible.builtin.systemd:
|
||||
service: bluetooth.service
|
||||
state: started
|
||||
enabled: true
|
||||
- name: Ensure audiosink user exists
|
||||
ansible.builtin.user:
|
||||
name: audiosink
|
||||
groups:
|
||||
- audio
|
||||
- name: Ensure user services are started without needing to login
|
||||
ansible.builtin.command:
|
||||
cmd: loginctl enable-linger audiosink
|
||||
changed_when: false
|
||||
- name: Detect if on Raspberry Pi # noqa ignore-errors
|
||||
ansible.builtin.include_role:
|
||||
name: raspberry_pi_check
|
||||
ignore_errors: true
|
||||
- name: Ensure debian archive keyring is installed # noqa no-handler
|
||||
when: raspberry_pi_check__cpuinfo.found
|
||||
ansible.builtin.apt:
|
||||
deb: https://ftp.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2021.1.1_all.deb
|
||||
- name: Ensure debian backports repository is enabled
|
||||
ansible.builtin.include_role:
|
||||
name: add_apt_repository
|
||||
vars:
|
||||
add_apt_repository__https_repo: false
|
||||
add_apt_repository__repo: "deb http://deb.debian.org/debian {{ ansible_facts.lsb.codename }}-backports main contrib non-free"
|
||||
add_apt_repository__filename: "{{ ansible_facts.lsb.codename }}-backports.list"
|
||||
- name: Ensure pipewire, wireplumber and libspa-0.2-bluetooth are installed
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- pipewire
|
||||
- wireplumber
|
||||
- libspa-0.2-bluetooth
|
||||
default_release: "{{ ansible_facts.lsb.codename }}-backports"
|
||||
- name: Ensure pipewire user service is enabled and started
|
||||
become_user: audiosink
|
||||
ansible.builtin.systemd:
|
||||
name: pipewire.service
|
||||
state: started
|
||||
enabled: true
|
||||
scope: user
|
||||
- name: Ensure pipewire-pulse user service is enabled and started
|
||||
become_user: audiosink
|
||||
ansible.builtin.systemd:
|
||||
name: pipewire-pulse.service
|
||||
state: started
|
||||
enabled: true
|
||||
scope: user
|
||||
- name: Ensure wireplumber user service is enabled
|
||||
become_user: audiosink
|
||||
ansible.builtin.systemd:
|
||||
name: wireplumber.service
|
||||
enabled: true
|
||||
scope: user
|
||||
- name: Ensure speaker-agent dependencies are installed
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- git
|
||||
- python3-dbus
|
||||
- name: Ensure speaker-agent repository is cloned
|
||||
ansible.builtin.git:
|
||||
repo: https://github.com/fdanis-oss/pw_wp_bluetooth_rpi_speaker.git
|
||||
dest: /opt/speaker-agent
|
||||
version: 9a939a23865ea020816017e06fd2290f301c35f9
|
||||
- name: Ensure .config directory exists
|
||||
become_user: audiosink
|
||||
ansible.builtin.file:
|
||||
path: /home/audiosink/.config
|
||||
state: directory
|
||||
mode: 0700
|
||||
owner: audiosink
|
||||
group: audiosink
|
||||
- name: Ensure .config/systemd directory exists
|
||||
become_user: audiosink
|
||||
ansible.builtin.file:
|
||||
path: /home/audiosink/.config/systemd
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: audiosink
|
||||
group: audiosink
|
||||
- name: Ensure .config/systemd/user directory exists
|
||||
become_user: audiosink
|
||||
ansible.builtin.file:
|
||||
path: /home/audiosink/.config/systemd/user
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: audiosink
|
||||
group: audiosink
|
||||
- name: Ensure speaker-agent service file is deployed
|
||||
become_user: audiosink
|
||||
ansible.builtin.copy:
|
||||
src: speaker-agent.service
|
||||
dest: /home/audiosink/.config/systemd/user/speaker-agent.service
|
||||
mode: 0644
|
||||
owner: audiosink
|
||||
group: audiosink
|
||||
notify: Restart speaker-agent service
|
||||
- name: Ensure speaker-agent service is enabled and started
|
||||
become_user: audiosink
|
||||
ansible.builtin.systemd:
|
||||
name: speaker-agent.service
|
||||
state: started
|
||||
enabled: true
|
||||
scope: user
|
||||
# This part is janky, but I don't know how to make the bluetooth service, wireplumber and pipewire
|
||||
# work with each other without being logged in.
|
||||
- name: Ensure getty@tty1 override file is deployed
|
||||
ansible.builtin.copy:
|
||||
src: override.conf
|
||||
dest: /etc/systemd/system/getty@tty1.service.d/override.conf
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: Reboot host
|
||||
- name: Ensure autologin for audiosink user is enabled
|
||||
ansible.builtin.systemd:
|
||||
service: getty@tty1.service
|
||||
enabled: true
|
||||
notify: Reboot host
|
||||
3
playbooks/roles/cert/defaults/main.yaml
Normal file
3
playbooks/roles/cert/defaults/main.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
cert__handlers: []
|
||||
cert__owner: root
|
||||
cert__group: root
|
||||
32
playbooks/roles/cert/meta/argument_specs.yaml
Normal file
32
playbooks/roles/cert/meta/argument_specs.yaml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
argument_specs:
|
||||
main:
|
||||
short_description: Orders and renews certificates from Let's Encrypt
|
||||
options:
|
||||
cert__domains:
|
||||
description: Domains for which to issue a certificate. Must be in the same DNS zone.
|
||||
required: true
|
||||
type: list
|
||||
elements: str
|
||||
cert__owner:
|
||||
description: Owner of the certificate files.
|
||||
required: false
|
||||
type: str
|
||||
default: root
|
||||
cert__group:
|
||||
description: Group of the certificate files.
|
||||
required: false
|
||||
type: str
|
||||
default: root
|
||||
cert__acme_account_email:
|
||||
description: E-Mail address for ACME account
|
||||
required: true
|
||||
type: str
|
||||
cert__bind_9_host:
|
||||
description: The machine running BIND 9.
|
||||
required: true
|
||||
type: str
|
||||
cert__bind_9_zone:
|
||||
description: The zone to use for publishing the TXT record.
|
||||
required: true
|
||||
type: str
|
||||
7
playbooks/roles/cert/meta/main.yaml
Normal file
7
playbooks/roles/cert/meta/main.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
dependencies: # noqa meta-no-info
|
||||
- role: distribution_check
|
||||
vars:
|
||||
distribution_check__supported_distributions:
|
||||
- name: Debian
|
||||
versions:
|
||||
- "11"
|
||||
174
playbooks/roles/cert/tasks/deploy_cert.yaml
Normal file
174
playbooks/roles/cert/tasks/deploy_cert.yaml
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
- name: Ensure `ansible_certs` directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/ansible_certs
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "755"
|
||||
become: true
|
||||
|
||||
- name: Ensure `certs` sub-directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/ansible_certs/certs
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "755"
|
||||
become: true
|
||||
|
||||
- name: Ensure sub-directory for the certificate exists
|
||||
ansible.builtin.file:
|
||||
path: "/etc/ansible_certs/certs/{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ cert__owner }}"
|
||||
group: "{{ cert__group }}"
|
||||
mode: "755"
|
||||
become: true
|
||||
|
||||
- name: Ensure private key for certificate exists
|
||||
community.crypto.openssl_privatekey:
|
||||
path: "/etc/ansible_certs/certs/{{ item }}/privkey.pem"
|
||||
size: 4096
|
||||
type: RSA
|
||||
owner: "{{ cert__owner }}"
|
||||
group: "{{ cert__group }}"
|
||||
mode: "0600"
|
||||
become: true
|
||||
|
||||
- name: Ensure certificate signing request is created
|
||||
community.crypto.openssl_csr:
|
||||
path: "/etc/ansible_certs/certs/{{ item }}/csr.pem"
|
||||
privatekey_path: "/etc/ansible_certs/certs/{{ item }}/privkey.pem"
|
||||
common_name: "{{ item }}"
|
||||
owner: "{{ cert__owner }}"
|
||||
group: "{{ cert__group }}"
|
||||
mode: "0660"
|
||||
become: true
|
||||
register: cert__csr_result
|
||||
|
||||
- name: Ensure private key for ACME account exists
|
||||
community.crypto.openssl_privatekey:
|
||||
path: "/etc/ansible_certs/account_key.pem"
|
||||
size: 4096
|
||||
type: RSA
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
become: true
|
||||
|
||||
- name: Check certificate status and create ACME challenge if needed
|
||||
community.crypto.acme_certificate:
|
||||
account_email: "{{ cert__acme_account_email }}"
|
||||
account_key_src: "/etc/ansible_certs/account_key.pem"
|
||||
acme_directory: https://acme-v02.api.letsencrypt.org/directory
|
||||
acme_version: 2
|
||||
remaining_days: 28
|
||||
terms_agreed: true
|
||||
challenge: dns-01
|
||||
csr: "/etc/ansible_certs/certs/{{ item }}/csr.pem"
|
||||
dest: "/etc/ansible_certs/certs/{{ item }}/cert.pem"
|
||||
fullchain_dest: "/etc/ansible_certs/certs/{{ item }}/fullchain.pem"
|
||||
become: true
|
||||
register: cert__acme_challenge
|
||||
|
||||
- name: Retrieve certificate and fulfill challenge if needed # noqa no-handler
|
||||
when: cert__acme_challenge.changed # Can't be put in a handler, because then the block "always" tasks won't be executed for some reason
|
||||
block:
|
||||
- name: Add file containing nsupdate commands for adding TXT record for DNS-01 challenge
|
||||
ansible.builtin.template:
|
||||
src: nsupdate_add_txt_record.j2
|
||||
dest: /root/nsupdate_add_txt_record
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
vars:
|
||||
cert__nsupdate_domain: "{{ cert__acme_challenge.challenge_data[item]['dns-01'].record }}"
|
||||
cert__nsupdate_txt_data: "{{ cert__acme_challenge.challenge_data[item]['dns-01'].resource_value }}"
|
||||
delegate_to: "{{ cert__bind_9_host }}"
|
||||
|
||||
- name: Add DNS record to BIND 9 server via nsupdate # noqa: no-changed-when
|
||||
ansible.builtin.command: /usr/bin/nsupdate -l /root/nsupdate_add_txt_record
|
||||
delegate_to: "{{ cert__bind_9_host }}"
|
||||
|
||||
- name: Retrieve certificate
|
||||
community.crypto.acme_certificate:
|
||||
account_email: "{{ cert__acme_account_email }}"
|
||||
account_key_src: "/etc/ansible_certs/account_key.pem"
|
||||
acme_directory: https://acme-v02.api.letsencrypt.org/directory
|
||||
acme_version: 2
|
||||
terms_agreed: true
|
||||
remaining_days: 28
|
||||
challenge: dns-01
|
||||
csr: "/etc/ansible_certs/certs/{{ item }}/csr.pem"
|
||||
dest: "/etc/ansible_certs/certs/{{ item }}/cert.pem"
|
||||
fullchain_dest: "/etc/ansible_certs/certs/{{ item }}/fullchain.pem"
|
||||
data: "{{ cert__acme_challenge }}"
|
||||
become: true
|
||||
notify: "{{ cert__handlers }}"
|
||||
always:
|
||||
- name: Remove file containing nsupdate commands for adding TXT record again
|
||||
ansible.builtin.file:
|
||||
path: /root/nsupdate_add_txt_record
|
||||
state: absent
|
||||
delegate_to: "{{ cert__bind_9_host }}"
|
||||
|
||||
- name: Remove TXT record again
|
||||
block:
|
||||
- name: Add file containing nsupdate commands for deleting TXT record for DNS-01 challenge
|
||||
ansible.builtin.template:
|
||||
src: nsupdate_delete_txt_record.j2
|
||||
dest: /root/nsupdate_delete_txt_record
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
vars:
|
||||
cert__nsupdate_domain: "{{ cert__acme_challenge.challenge_data[item]['dns-01'].record }}"
|
||||
cert__nsupdate_txt_data: "{{ cert__acme_challenge.challenge_data[item]['dns-01'].resource_value }}"
|
||||
delegate_to: "{{ cert__bind_9_host }}"
|
||||
|
||||
- name: Remove DNS record from BIND 9 server via nsupdate # noqa: no-changed-when
|
||||
ansible.builtin.command: /usr/bin/nsupdate -l /root/nsupdate_delete_txt_record
|
||||
delegate_to: "{{ cert__bind_9_host }}"
|
||||
always:
|
||||
- name: Remove file containing nsupdate commands for deleting TXT record again
|
||||
ansible.builtin.file:
|
||||
path: /root/nsupdate_delete_txt_record
|
||||
state: absent
|
||||
delegate_to: "{{ cert__bind_9_host }}"
|
||||
|
||||
- name: Ensure correct permissions for certificate are set
|
||||
ansible.builtin.file:
|
||||
path: "/etc/ansible_certs/certs/{{ item }}/cert.pem"
|
||||
owner: "{{ cert__owner }}"
|
||||
group: "{{ cert__group }}"
|
||||
mode: "0660"
|
||||
become: true
|
||||
|
||||
- name: Ensure correct permissions for fullchain cert are set
|
||||
ansible.builtin.file:
|
||||
path: "/etc/ansible_certs/certs/{{ item }}/fullchain.pem"
|
||||
owner: "{{ cert__owner }}"
|
||||
group: "{{ cert__group }}"
|
||||
mode: "0660"
|
||||
become: true
|
||||
|
||||
- name: Get content of cert.pem
|
||||
ansible.builtin.slurp:
|
||||
src: "/etc/ansible_certs/certs/{{ item }}/cert.pem"
|
||||
become: true
|
||||
register: cert__cert_slurp
|
||||
|
||||
- name: Get content of fullchain.pem
|
||||
ansible.builtin.slurp:
|
||||
src: "/etc/ansible_certs/certs/{{ item }}/fullchain.pem"
|
||||
become: true
|
||||
register: cert__fullchain_slurp
|
||||
|
||||
- name: Ensure chain.pem is created
|
||||
ansible.builtin.copy:
|
||||
content: "{{ cert__fullchain_slurp.content | b64decode | replace(cert__cert_slurp.content | b64decode, '') }}"
|
||||
dest: "/etc/ansible_certs/certs/{{ item }}/chain.pem"
|
||||
owner: "{{ cert__owner }}"
|
||||
group: "{{ cert__group }}"
|
||||
mode: "0660"
|
||||
become: true
|
||||
3
playbooks/roles/cert/tasks/main.yaml
Normal file
3
playbooks/roles/cert/tasks/main.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
- name: Deploy cert
|
||||
ansible.builtin.include_tasks: deploy_cert.yml
|
||||
loop: "{{ cert__domains }}"
|
||||
18
playbooks/roles/distribution_check/meta/argument_specs.yaml
Normal file
18
playbooks/roles/distribution_check/meta/argument_specs.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
argument_specs:
|
||||
main:
|
||||
options:
|
||||
distribution_check__supported_distributions:
|
||||
description: A spec specifying the supported distribution.
|
||||
type: list
|
||||
elements: dict
|
||||
required: true
|
||||
options:
|
||||
name:
|
||||
description: The name of the supported distribution.
|
||||
type: str
|
||||
required: true
|
||||
versions:
|
||||
description: The supported versions of the supported distribution.
|
||||
type: list
|
||||
elements: str
|
||||
required: true
|
||||
20
playbooks/roles/distribution_check/tasks/main.yaml
Normal file
20
playbooks/roles/distribution_check/tasks/main.yaml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
- name: Set fact holding list of supported distribution names
|
||||
ansible.builtin.set_fact:
|
||||
distribution_check__supported_distribution_names: "{{ distribution_check__supported_distributions | community.general.json_query('[].name') }}"
|
||||
|
||||
- name: Fail on unsupported distribution (name)
|
||||
ansible.builtin.fail:
|
||||
msg: The hosts distribution (name) isn't supported.
|
||||
when: ansible_facts.distribution not in distribution_check__supported_distribution_names
|
||||
|
||||
- name: Set fact holding list of supported distribution versions
|
||||
ansible.builtin.set_fact:
|
||||
distribution_check__supported_distribution_versions: "{{ distribution_check__supported_distributions
|
||||
| community.general.json_query(distribution_check__supported_distribution_versions_query) }}"
|
||||
vars:
|
||||
distribution_check__supported_distribution_versions_query: "[?name=='{{ ansible_facts.distribution }}'].versions | [].to_string(@)"
|
||||
|
||||
- name: Fail on unsupported distribution version
|
||||
ansible.builtin.fail:
|
||||
msg: The hosts distribution version isn't supported.
|
||||
when: ansible_facts.distribution_version not in distribution_check__supported_distribution_versions
|
||||
6
playbooks/roles/esphome/handlers/main.yaml
Normal file
6
playbooks/roles/esphome/handlers/main.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Restart esphome
|
||||
ansible.builtin.systemd:
|
||||
service: esphome.service
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue