Skip to content

Instantly share code, notes, and snippets.

@BorysVrublevskyi
Last active February 7, 2024 14:26
Show Gist options
  • Save BorysVrublevskyi/509113f7b999c56a53d46274bc503c36 to your computer and use it in GitHub Desktop.
Save BorysVrublevskyi/509113f7b999c56a53d46274bc503c36 to your computer and use it in GitHub Desktop.
Ansible-cheatsheet.md

Vault

ansible-vault create --vault-id zabbix@~/ans-ps-file ~/ans-vault-zabbix.yml
ansible-vault view --vault-id zabbix@~/ans-ps-file ~/ans-vault-zabbix.yml
ansible-vault view --vault-pass-file ~/ans-ps-file ~/ans-vault-zabbix.yml
# rekey it!

Local dynamic inventory (nmap)

# cat lan-nmap.yml
plugin: nmap
address: 192.168.1.0/24
exclude: 192.168.1.2, zabbix
ports: false
# strict: false
ansible all -m nmap -i lan-nmap.yml --list | \
sed -E -e '/^[[:space:]]*(PC|pc)-?[[:digit:]]+.*$/d' -e 's/^[[:space:]]*hosts.*$/[all]/g' | \
tee lan.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment