Ansible: ssh-extra-args ProxyCommand๋Š” host_key_checking=False๋ฅผ ๋น„ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2016๋…„ 03์›” 11์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: ansible/ansible

๋ฌธ์ œ ์œ ํ˜•:
  • ๋ฒ„๊ทธ ์‹ ๊ณ 
    ์•ค์„œ๋ธ” ๋ฒ„์ „:
ansible 2.0.1.0
  config file = /Users/tpai/src/cm/ansible.cfg
  configured module search path = Default w/o overrides
์•ค์„œ๋ธ” ๊ตฌ์„ฑ:
[defaults]

host_key_checking=False
timeout=20
forks=20

force_handlers = True
roles_path = ./roles
callback_whitelist=profile_tasks
filter_plugins = ./filter_plugins

[ssh_connection]
pipelining = True
control_path = /tmp/ansible-ssh-%%h-%%p-%%r
ํ™˜๊ฒฝ:

์•ค์„œ๋ธ” ํ˜ธ์ŠคํŠธ : OS X 10.11.3
๋Œ€์ƒ : ์šฐ๋ถ„ํˆฌ 14.04.02

์š”์•ฝ:

ssh-extra-args ProxyCommand๋Š” host_key_checking=False ๋ฅผ ์ค‘๋‹จํ•ฉ๋‹ˆ๋‹ค.

ansible.cfg ๋˜๋Š” ssh-extra-args ์ž์ฒด์— ์„ค์ •๋œ host_key_checking=False ssh-extra-args ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์—ฐ๊ฒฐํ•˜์ง€ ์•Š์€ ํ˜ธ์ŠคํŠธ์˜ ํ‚ค๋ฅผ ์ˆ˜๋ฝํ•˜๋ผ๋Š” ๋ฉ”์‹œ์ง€๊ฐ€ ๊ณ„์† ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์ „์—.

์žฌํ˜„ ๋‹จ๊ณ„:
ansible-playbook provision_envs/configure-sid.yml -i inventory/sid --limit=tag_build_5 --vault-password-file ../vault_key --ssh-extra-args='-o ProxyCommand="ssh -W %h:%p [email protected]"' -vvvvv
์˜ˆ์ƒ ๊ฒฐ๊ณผ:

์ƒˆ ํ˜ธ์ŠคํŠธ์— ๋Œ€ํ•ด ํ”Œ๋ ˆ์ด๋ถ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

์‹ค์ œ ๊ฒฐ๊ณผ:

StrictHostKeyChecking ๊ฐ€ ํ™œ์„ฑํ™”๋œ ๊ฒƒ์ฒ˜๋Ÿผ ํ‚ค๋ฅผ ์ˆ˜๋ฝํ•˜๋ผ๋Š” ๋ฉ”์‹œ์ง€๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

$ ansible-playbook provision_envs/configure-sid.yml -i inventory/sid --limit=tag_build_5 --vault-password-file ../vault_key --ssh-extra-args='-o ProxyCommand="ssh -W %h:%p [email protected]"' -vvvvv
Using /Users/tpai/src/cm/ansible.cfg as config file
Loaded callback default of type stdout, v2.0
Loaded callback profile_tasks of type aggregate, v2.0
2 plays in provision_envs/configure-sid.yml

PLAY ***************************************************************************
skipping: no hosts matched

PLAY ***************************************************************************

TASK [setup] *******************************************************************
Friday 11 March 2016  12:40:12 +0000 (0:00:00.122)       0:00:00.122 **********
<10.0.251.222> ESTABLISH SSH CONNECTION FOR USER: user
<10.0.251.222> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<10.0.251.222> SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)
<10.0.251.222> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<10.0.251.222> SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=user)
<10.0.251.222> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=20)
<10.0.251.222> SSH: PlayContext set ssh_common_args: ()
<10.0.251.222> SSH: PlayContext set ssh_extra_args: (-o)(ProxyCommand=ssh -W %h:%p [email protected])
<10.0.251.222> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/tmp/ansible-ssh-%h-%p-%r)
<10.0.251.222> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user -o ConnectTimeout=20 -o 'ProxyCommand=ssh -W %h:%p [email protected]' -o ControlPath=/tmp/ansible-ssh-%h-%p-%r 10.0.251.222 '/bin/sh -c '"'"'LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 /usr/bin/python'"'"''
The authenticity of host 'host.com (1.2.3.4)' can't be established.
ECDSA key fingerprint is SHA256:kjghdfjkghdkfjghkdjfgdfgdfjghdkjfg.
Are you sure you want to continue connecting (yes/no)? 

**ssh connection times out**

fatal: [7.8.9.0]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}
        to retry, use: --limit @provision_envs/configure-sid.retry

PLAY RECAP *********************************************************************
7.8.9.0               : ok=0    changed=0    unreachable=1    failed=0

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ด๊ฒƒ์€ ๋ฒ„๊ทธ๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ํ•ด๋‹น ๋™์ž‘์„ ์›ํ•˜๋Š” ๊ฒฝ์šฐ ProxyCommand์— -o StrictHostKeyChecking=no ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Ansible์ด ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•œ ssh_extra_args ๋‚ด๋ถ€์˜ ProxyCommand์— ์ถ”๊ฐ€ ์ธ์ˆ˜๋ฅผ ์‹œ๋„ํ•˜๊ณ  ์‚ฝ์ž…ํ•˜๋Š” ๊ฒƒ์€ ๋งค์šฐ ํ˜„๋ช…ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  3 ๋Œ“๊ธ€

์ด๊ฒƒ์€ ๋ฒ„๊ทธ๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ํ•ด๋‹น ๋™์ž‘์„ ์›ํ•˜๋Š” ๊ฒฝ์šฐ ProxyCommand์— -o StrictHostKeyChecking=no ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Ansible์ด ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•œ ssh_extra_args ๋‚ด๋ถ€์˜ ProxyCommand์— ์ถ”๊ฐ€ ์ธ์ˆ˜๋ฅผ ์‹œ๋„ํ•˜๊ณ  ์‚ฝ์ž…ํ•˜๋Š” ๊ฒƒ์€ ๋งค์šฐ ํ˜„๋ช…ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

ํ™•์ธ, ์ž‘๋™:

ansible-playbook provision_envs/configure-sid.yml -i inventory/sid --limit=tag_build_5 --vault-password-file ../vault_key --ssh-extra-args='-o StrictHostKeyChecking=no  -o UserKnownHostsFile=/dev/null  -o ProxyCommand="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -W %h:%p [email protected]"'

์ด๊ฒƒ์„ ์‹œ๋„ํ–ˆ์ง€๋งŒ ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค ... ๋‚ด๊ฐ€ ๋ญ”๊ฐ€๋ฅผ ๋†“์น˜๊ณ  ์žˆ์Šต๋‹ˆ๊นŒ?

ansible-playbook --private-key aws_key.pem -u ์šฐ๋ถ„ํˆฌ -e --ssh-extra-args='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand="ssh -o StrictHostKeyChecking=no - o UserKnownHostsFile=/dev/null -W %h:%p [email protected] "' -i hosts.txt ./ansible/docker.yml

์—ฌ์ „ํžˆ ๋…ธํ•˜์šฐ๋ฅผ ์š”๊ตฌํ•ฉ๋‹ˆ๋‹ค

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰