인프라 툴

[Ansible] too long for unix domain socket 에러

eden.do 2025. 2. 21. 14:45

- 2023/03/23 작성

 

domain socket 이름을 디렉토리 + 서버 이름으로 되어 있는데 이 이름이 너무 길어서 에러가 나는 경우 발생

108자가 넘어가면 에러가 난다고 한다.(예전에는 104자였는데.. 4자 늘려줬다..) 아래 path 길이는 111자.

 

 

ansible.cfg의 control_path 이름을 어느정도까지만 나오게 지정하면 해결할 수 있다.

처음에 /etc/ansible/ansible.cfg 를 수정했는데 구성파일도 우선순위가 있다고 한다. https://docs.ansible.com/archive/ansible/2.4/intro_configuration.html

  1. ANSIBLE_CONFIG 환경 변수
  2. 현재 디렉토리의 ansible.cfg
  3. 홈 디렉토리의 ~/.ansible.cfg
  4. /etc/ansible/ansible.cfg

우선순위에 따라 덮어 씌워질 수 있다. 

git에 올라온 init_os_scripts_k9e에 ansible.cfg 가 있었다. %(directory)s/%%h-%%r 이게 ansible에서 에러 나면 지정하라고 알려주는 control_path인데 이것도 길어서 에러가 났다.

 

`

[defaults]
host_key_checking = False
forks = 50
gather_facts: no
internal_poll_interval = 0.001
retry_files_enabled = False
pipelining = true
 
[all:vars]
ansible_connection=ssh
#ansible_user="root"
 
[ssh_connection]
# http://docs.ansible.com/ansible/intro_configuration.html#control-path
# Or see ansible issue #11536: ssh 'unix domain socket too long error'
# https://github.com/ansible/ansible/issues/11536#issuecomment-153030743
# pipelining = true
control_path = %(directory)s/%%h-%%r

 

control_path:  path to the control socket used for connection

%%h : target_hostname

%%r:  remote login username 

%%C: hash of the concatenation: %l%h%p%r 

굳이 target_hostname과 remote login username이 온전히 포함될 필요는 없음. 

%(directory)s/%%C 로 변경 완료

https://copyprogramming.com/howto/no-ansible-config-file-or-etc-ansible-directory-after-trying-pip-and-yum-install