mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
9 core roles check their vars + 3 roles record to iiab_state.yml
This commit is contained in:
parent
624fb68596
commit
d87821d266
37 changed files with 737 additions and 416 deletions
|
|
@ -1,31 +1,33 @@
|
|||
- name: Enable & Restart 'bt-agent' service
|
||||
- name: systemd daemon-reload
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: bluetooth
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
||||
# enable or disable bt-agent
|
||||
- name: Enable & Restart 'bt-agent' service
|
||||
|
||||
# enable or disable both... bluetooth and bt-agent
|
||||
- name: 'Enable & Restart 2 services: bluetooth, bt-agent'
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: bt-agent
|
||||
name: "{{ item }}"
|
||||
enabled: yes
|
||||
state: restarted
|
||||
with_items:
|
||||
- bluetooth
|
||||
- bt-agent
|
||||
when: bluetooth_enabled or bluetooth_term_enabled
|
||||
|
||||
- name: Disable 'bt-agent' service
|
||||
- name: 'Disable 2 services: bluetooth, bt-agent'
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: bt-agent
|
||||
name: "{{ item }}"
|
||||
enabled: no
|
||||
state: stopped
|
||||
with_items:
|
||||
- bluetooth
|
||||
- bt-agent
|
||||
when: not bluetooth_enabled and not bluetooth_term_enabled
|
||||
|
||||
|
||||
# enable or disable bt-pan
|
||||
- name: Enable & Restart 'bt-pan' service
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: bt-pan
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
|
@ -33,16 +35,15 @@
|
|||
|
||||
- name: Disable 'bt-pan' service
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: bt-pan
|
||||
enabled: no
|
||||
state: stopped
|
||||
when: not bluetooth_enabled | bool
|
||||
when: not bluetooth_enabled
|
||||
|
||||
|
||||
# enable or disable bt-term
|
||||
- name: Enable & Restart 'bt-term' service
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: bt-term
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
|
@ -50,24 +51,7 @@
|
|||
|
||||
- name: Disable 'bt-term' service
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: bt-term
|
||||
enabled: no
|
||||
state: stopped
|
||||
when: not bluetooth_term_enabled | bool
|
||||
|
||||
- name: Add 'bluetooth' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}"
|
||||
section: bluetooth
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
with_items:
|
||||
- option: name
|
||||
value: Bluetooth
|
||||
- option: description
|
||||
value: '"Bluetooth services for pan and terminal."'
|
||||
- option: bluetooth_enabled
|
||||
value: "{{ bluetooth_enabled }}"
|
||||
- option: bluetooth_term_enabled
|
||||
value: "{{ bluetooth_term_enabled }}"
|
||||
when: not bluetooth_term_enabled
|
||||
|
|
|
|||
|
|
@ -1,6 +1,44 @@
|
|||
- include_tasks: install.yml
|
||||
when: bluetooth_install and not bluetooth_installed is defined
|
||||
# "How do i fail a task in Ansible if the variable contains a boolean value?
|
||||
# I want to perform input validation for Ansible playbooks"
|
||||
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
|
||||
|
||||
- include_tasks: enable.yml
|
||||
when: bluetooth_install or bluetooth_installed is defined
|
||||
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
|
||||
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
|
||||
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
|
||||
|
||||
- name: Assert that "bluetooth_install is sameas true" (boolean not string etc)
|
||||
assert:
|
||||
that: bluetooth_install is sameas true
|
||||
fail_msg: "PLEASE SET 'bluetooth_install: True' e.g. IN: /etc/iiab/local_vars.yml"
|
||||
quiet: yes
|
||||
|
||||
- name: Assert that "bluetooth_enabled | type_debug == 'bool'" (boolean not string etc)
|
||||
assert:
|
||||
that: bluetooth_enabled | type_debug == 'bool'
|
||||
fail_msg: "PLEASE GIVE VARIABLE 'bluetooth_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
|
||||
quiet: yes
|
||||
|
||||
|
||||
- name: Install Bluetooth if 'bluetooth_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
|
||||
include_tasks: install.yml
|
||||
when: bluetooth_installed is undefined
|
||||
|
||||
|
||||
- include_tasks: enable.yml # i.e. enable-or-disable.yml in other roles
|
||||
|
||||
|
||||
- name: Add 'bluetooth' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||
section: bluetooth
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
with_items:
|
||||
- option: name
|
||||
value: Bluetooth
|
||||
- option: description
|
||||
value: '"Bluetooth services for pan and terminal."'
|
||||
- option: bluetooth_enabled
|
||||
value: "{{ bluetooth_enabled }}"
|
||||
- option: bluetooth_term_enabled
|
||||
value: "{{ bluetooth_term_enabled }}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue