ansible
差别
这里会显示出您选择的修订版和当前版本之间的差别。
后一修订版 | 前一修订版 | ||
ansible [2017/08/02 04:10] – 创建 memory | ansible [2023/12/03 02:24] (当前版本) – 外部编辑 127.0.0.1 | ||
---|---|---|---|
行 4: | 行 4: | ||
==== Add public key to server ==== | ==== Add public key to server ==== | ||
+ | |||
+ | 0. Install '' | ||
+ | |||
+ | sudo pacman -S sshpass | ||
1. Edit host inventory, add server host like this: | 1. Edit host inventory, add server host like this: | ||
行 10: | 行 14: | ||
[test] | [test] | ||
test1 ansible_ssh_host=1.1.1.1 | test1 ansible_ssh_host=1.1.1.1 | ||
+ | test2 ansible_ssh_host=2.2.2.2 | ||
</ | </ | ||
行 26: | 行 31: | ||
</ | </ | ||
- | 3. Run '' | + | 3. Run '' |
- | ansible-playbook -l test upload_ssh_keys.yml | + | ansible-playbook |
+ | |||
+ | ==== Handling SSH host key prompts ==== | ||
+ | |||
+ | When you first time connected to server, it would prompts you something like this: | ||
+ | |||
+ | The authenticity of host 'xxx (x.x.x.x)' | ||
+ | ED25519 key fingerprint is xxxxxxxx. | ||
+ | Are you sure you want to continue connecting (yes/no)? | ||
+ | |||
+ | Solution: disable SSH key host checking: | ||
+ | |||
+ | <code ini ansible.cfg> | ||
+ | [defaults] | ||
+ | host_key_checking = False | ||
+ | </ | ||
+ | |||
+ | ===== Tips ===== | ||
+ | |||
+ | ==== Set global host inventory variables ==== | ||
+ | |||
+ | <code ini host> | ||
+ | [all: | ||
+ | ansible_port=22 | ||
+ | ansible_user=root | ||
+ | ansible_ssh_private_key_file=" | ||
+ | </ | ||
+ | |||
+ | ==== Usage of sub-group ==== | ||
+ | |||
+ | <code ini host> | ||
+ | [test-db] | ||
+ | test-db1 ansible_host=1.1.1.1 | ||
+ | |||
+ | [test-api] | ||
+ | test-api1 ansible_host=2.2.2.2 | ||
+ | test-api2 ansible_host=3.3.3.3 | ||
+ | |||
+ | [test: | ||
+ | test-db | ||
+ | test-api | ||
+ | </ |
ansible.1501647016.txt.gz · 最后更改: (外部编辑)