notebook/IT/Ansible/index.md

38 lines
829 B
Markdown
Raw Permalink Normal View History

2020-11-26 17:38:25 +00:00
# ansible
2021-04-20 18:56:58 +00:00
2022-10-09 14:36:39 +00:00
![ansible](../img/ansible.png)
2021-04-20 18:56:58 +00:00
2020-11-26 17:38:25 +00:00
## commande ansible
2022-04-27 06:38:23 +00:00
**_launch playbook on staging_**
`ansible-playbook -i staging site.yml --vault-password-file=.vaultpassword`
2020-11-26 17:38:25 +00:00
2022-04-27 06:38:23 +00:00
**_init new role architecture_**
2021-04-20 18:56:58 +00:00
`ansible-galaxy user_config init`
2022-04-27 06:38:23 +00:00
**_launch ansible bootstrap_**
2021-04-20 18:56:58 +00:00
`ansible-playbook -i nas, bootstrap.yml -u root --ask-pass`
2020-11-26 17:38:25 +00:00
2022-04-27 06:38:23 +00:00
**_encrypt string_**
2020-11-26 17:38:25 +00:00
`ansible-vault encrypt_string`
2021-04-20 18:56:58 +00:00
## ignore know host file on ansible
```bash
2020-11-26 17:38:25 +00:00
export ANSIBLE_HOST_KEY_CHECKING=False
--ssh-extra-args='-o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null'
2021-01-24 16:52:22 +00:00
```
2022-04-27 06:38:23 +00:00
## Merge Dict instead Replace
in ansible config file set
2022-10-05 21:02:31 +00:00
```config
2022-04-27 06:38:23 +00:00
hash_behaviour = merge
```
2023-11-01 08:30:37 +00:00
## test ansible template in local
```sh
2023-11-01 08:38:00 +00:00
ansible -m debug -a "msg='{{ lookup('template','./daemon.json.j2')}}'" --extra-vars=@../../../group_vars/all/docker localhost
2023-11-01 08:30:37 +00:00
```