2021-07-13 05:42:49 +00:00
# TEST ANSIBLE COMMANDS/MODULES IN SECONDS -- BY RUNNING:
# ansible-playbook -i ansible_hosts test.yml --connection=local
2024-08-15 14:00:56 +00:00
# TEST A SINGLE ANSIBLE COMMAND/MODULE:
# ansible localhost -m ansible.builtin.setup | grep -e "ansible_machine\b" -e ansible_architecture
# ansible localhost -m ansible.builtin.shell -a 'echo $TERM'
# ansible localhost -m ansible.builtin.copy -a "src=/etc/hosts dest=/tmp/hosts"
# ansible localhost -m ansible.builtin.systemd -a "name=nginx state=restarted"
# https://docs.ansible.com/ansible/latest/command_guide/intro_adhoc.html
2021-07-13 05:42:49 +00:00
- hosts : all
become : yes # Optional privilege escalation
#vars_files:
2022-06-22 15:58:22 +00:00
# - roles/0-init/defaults/main.yml
# - vars/default_vars.yml
# - vars/{{ ansible_local.local_facts.os_ver }}.yml
# - /etc/iiab/local_vars.yml
# - /etc/iiab/iiab_state.yml
2021-07-13 05:42:49 +00:00
#roles:
# - { role: 0-init }
tasks :
#- include_role:
# name: 0-init
2024-08-15 14:00:56 +00:00
# 2024-08-15: Still not working with ansible-core 2.17.3 -- instead of
# migrating from Python's crypt library to passlib, Ansible is deprecating:
# https://github.com/ansible/ansible/issues/81949
2024-05-16 22:01:17 +00:00
# https://github.com/iiab/iiab/blob/485a619bfa082716ec848b5b34893dd3046175a8/roles/cups/tasks/install.yml#L70-L78
#- debug:
# msg: "{{ 'changeme' | password_hash('sha512') }}"
2021-08-19 01:47:46 +00:00
# msg: "{{ 'changeme' | password_hash('yescrypt') }}" # crypt.crypt STILL doesn't support 'yescrypt' algorithm ?
2021-07-13 05:42:49 +00:00
#- pause:
2024-05-16 22:01:17 +00:00
- debug :
var : "'3.12.3' is version('3.12', '<')"
2022-08-31 20:27:29 +00:00
- name : DOUBLE UP to escape single quotes... '"''"' e.g. iiab.ini descriptions for azuracast, captiveportal, mosquitto, munin, nodejs, osm-vector-maps, sshd
2021-07-13 21:56:02 +00:00
debug :
2023-05-01 15:21:39 +00:00
msg : '"' '"' # OR: '''' FAILS: '"\'"'
2021-07-13 21:56:02 +00:00
- name : BACKSLASH to escape double quotes... "'\"'" e.g. cups/tasks/install.yml
debug :
2023-05-01 15:21:39 +00:00
msg : "'\"'" # OR: "\"" FAILS: "'""'"
- name : "Entire string must be enclosed in quotes if using ' #' Space-then-Pound/Hash sequence -- or right side will be a comment! e.g. roles/vnstat/install.yml"
debug :
msg : "Left side # Right side"
2021-07-13 05:42:49 +00:00
2021-10-29 04:11:56 +00:00
- name : a shows "VARIABLE IS NOT DEFINED!" -- whereas b (w/o whitespace) AND c (with space) AND d (with tab, STRICTLY DISALLOWED IN YAML BY ansible-core 2.11.6) showed null (without quotes!) -- whereas e (singlequotes) and f (doublequotes) show "" empty string
2021-08-19 01:47:46 +00:00
set_fact :
2022-06-21 00:13:41 +00:00
#a: # Tabs NO LONGER ALLOWED, in strict YAML: https://stackoverflow.com/a/19976827
2021-08-19 01:47:46 +00:00
b :
c : # Space
2022-06-21 00:13:41 +00:00
d : ''
e : ""
f : "3.10" # zero preserved b/c AnsibleUnicode (i.e. string)
g : +03.10 # plus sign & zeros dropped b/c float
2021-08-19 01:47:46 +00:00
- debug :
2022-06-21 00:13:41 +00:00
var : a # "VARIABLE IS NOT DEFINED!"
2021-08-19 01:47:46 +00:00
- debug :
2022-06-21 00:13:41 +00:00
var : a | type_debug # AnsibleUndefined
2021-08-19 01:47:46 +00:00
- debug :
2022-06-21 00:13:41 +00:00
var : b # null
2021-08-19 01:47:46 +00:00
- debug :
2022-06-21 00:13:41 +00:00
var : b | type_debug # NoneType
2021-08-19 01:47:46 +00:00
- debug :
2022-06-21 00:13:41 +00:00
var : c # null
2021-08-19 01:47:46 +00:00
- debug :
2022-06-21 00:13:41 +00:00
var : c | type_debug # NoneType
- debug :
var : d # ""
- debug :
var : d | type_debug # AnsibleUnicode
- debug :
var : e # ""
- debug :
var : e | type_debug # AnsibleUnicode
- debug :
var : f # "3.10"
- debug :
var : f | type_debug # AnsibleUnicode
- debug :
var : g # 3.1
- debug :
var : g | type_debug # float
2021-08-19 01:47:46 +00:00
2022-06-07 05:06:29 +00:00
- debug :
2022-06-07 17:52:20 +00:00
var: ansible_local.local_facts # SEE : /opt/iiab/iiab/scripts/local_facts.fact
2022-06-07 05:06:29 +00:00
- debug :
var : ansible_local.local_facts.os_ver
2022-06-07 17:52:20 +00:00
# Since Ansible 2.7, avoid ansible_distribution: https://github.com/iiab/iiab/pull/3237
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#commonly-used-facts
- debug :
var : ansible_facts['distribution'] # ansible_facts.distribution ?
- debug :
var : ansible_facts['os_family'] # ansible_facts.os_family ?
- debug :
var : ansible_facts['distribution_major_version'] # ansible_facts.distribution_major_version ?
2022-06-07 05:06:29 +00:00
- debug :
var : ansible_architecture
- debug :
var : ansible_machine
2023-03-31 13:39:53 +00:00
- command : dpkg --print-architecture
register : cmd
- debug :
msg : "'dpkg --print-architecture' output: {{ cmd.stdout }}"
- command : dpkg --print-foreign-architectures
register : cmd
- debug :
msg : "'dpkg --print-foreign-architectures' output: {{ cmd.stdout }}"
2021-07-13 05:42:49 +00:00
# TEST ANSIBLE COMMANDS/MODULES HERE!
2022-06-21 00:13:41 +00:00