CentOS 6.7 테스트 박스에 nginx를 설치하고 시작하려고 합니다.
내 스크립트
---
- hosts: testing
tasks:
- name: Install nginx package
yum: name=http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm state=present
sudo: yes
- name: Starting nginx service
service: name=nginx state=started
sudo: yes
내가 얻는 것:
ansible-playbook playbooks/setup_nginx.yml -vvvv
PLAY [testing] ****************************************************************
GATHERING FACTS ***************************************************************
<192.168.1.7> ESTABLISH CONNECTION FOR USER: root
<192.168.1.7> REMOTE_MODULE setup
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1440082617.5-357433622496 && echo $HOME/.ansible/tmp/ansible-tmp-1440082617.5-357433622496'
<192.168.1.7> PUT /tmp/tmpDVadb0 TO /root/.ansible/tmp/ansible-tmp-1440082617.5-357433622496/setup
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1440082617.5-357433622496/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1440082617.5-357433622496/ >/dev/null 2>&1'
ok: [192.168.1.7]
TASK: [Starting nginx service] ************************************************
<192.168.1.7> ESTABLISH CONNECTION FOR USER: root
<192.168.1.7> REMOTE_MODULE service name=nginx state=started
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1440082618.06-217670671742177 && echo $HOME/.ansible/tmp/ansible-tmp-1440082618.06-217670671742177'
<192.168.1.7> PUT /tmp/tmpS9pPju TO /root/.ansible/tmp/ansible-tmp-1440082618.06-217670671742177/service
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=mhcceyzpppkgjqdohbazdghdyxzgozkq] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-mhcceyzpppkgjqdohbazdghdyxzgozkq; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1440082618.06-217670671742177/service; rm -rf /root/.ansible/tmp/ansible-tmp-1440082618.06-217670671742177/ >/dev/null 2>&1'"'"''
failed: [192.168.1.7] => {"failed": true}
msg: no service or tool found for: nginx
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/root/setup_nginx.retry
192.168.1.7 : ok=1 changed=0 unreachable=0 failed=1
이것은 버그입니까, 아니면 스크립트에서 뭔가 잘못하고 있습니까? 감사해요.
다음에 추가
"nginx 서비스 시작" 작업이 실패한 것 같습니다.
ansible-playbook playbooks/setup_nginx.yml -vvvv
PLAY [testing] ****************************************************************
GATHERING FACTS ***************************************************************
<192.168.1.7> ESTABLISH CONNECTION FOR USER: root
<192.168.1.7> REMOTE_MODULE setup
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1440146573.93-179846503048866 && echo $HOME/.ansible/tmp/ansible-tmp-1440146573.93-179846503048866'
<192.168.1.7> PUT /tmp/tmprLXtDd TO /root/.ansible/tmp/ansible-tmp-1440146573.93-179846503048866/setup
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1440146573.93-179846503048866/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1440146573.93-179846503048866/ >/dev/null 2>&1'
ok: [192.168.1.7]
TASK: [Setting up nginx repository] *******************************************
<192.168.1.7> ESTABLISH CONNECTION FOR USER: root
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'rc=flag; [ -r /etc/yum.repos.d/nginx.repo ] || rc=2; [ -f /etc/yum.repos.d/nginx.repo ] || rc=1; [ -d /etc/yum.repos.d/nginx.repo ] && rc=3; python -V 2>/dev/null || rc=4; [ x"$rc" != "xflag" ] && echo "${rc} "/etc/yum.repos.d/nginx.repo && exit 0; (python -c '"'"'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile = open("'"'"'/etc/yum.repos.d/nginx.repo'"'"'", "rb") buf = afile.read(BLOCKSIZE) while len(buf) > 0: hasher.update(buf) buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())'"'"' 2>/dev/null) || (python -c '"'"'import sha; BLOCKSIZE = 65536; hasher = sha.sha(); afile = open("'"'"'/etc/yum.repos.d/nginx.repo'"'"'", "rb") buf = afile.read(BLOCKSIZE) while len(buf) > 0: hasher.update(buf) buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())'"'"' 2>/dev/null) || (echo '"'"'0 '"'"'/etc/yum.repos.d/nginx.repo)'
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1440146577.61-182195475857563 && echo $HOME/.ansible/tmp/ansible-tmp-1440146577.61-182195475857563'
<192.168.1.7> PUT /tmp/tmpWef98J TO /root/.ansible/tmp/ansible-tmp-1440146577.61-182195475857563/file
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=nexyrajvvcwztliiwybfvivgrzfjsksq] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-nexyrajvvcwztliiwybfvivgrzfjsksq; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1440146577.61-182195475857563/file; rm -rf /root/.ansible/tmp/ansible-tmp-1440146577.61-182195475857563/ >/dev/null 2>&1'"'"''
ok: [192.168.1.7] => {"changed": false, "checksum": "39e5562257da539bf330df83d33879d3aa32ad67", "dest": "/etc/yum.repos.d/nginx.repo", "gid": 0, "group": "root", "mode": "0644", "owner": "root", "path": "/etc/yum.repos.d/nginx.repo", "secontext": "unconfined_u:object_r:etc_t:s0", "size": 109, "state": "file", "uid": 0}
TASK: [Install nginx package] *************************************************
<192.168.1.7> ESTABLISH CONNECTION FOR USER: root
<192.168.1.7> REMOTE_MODULE yum name=http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm state=present
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1440146578.31-123436309041285 && echo $HOME/.ansible/tmp/ansible-tmp-1440146578.31-123436309041285'
<192.168.1.7> PUT /tmp/tmpcr7txw TO /root/.ansible/tmp/ansible-tmp-1440146578.31-123436309041285/yum
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=kocdoeeplindfbghqgvyngpfyybjxwap] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-kocdoeeplindfbghqgvyngpfyybjxwap; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python -tt /root/.ansible/tmp/ansible-tmp-1440146578.31-123436309041285/yum; rm -rf /root/.ansible/tmp/ansible-tmp-1440146578.31-123436309041285/ >/dev/null 2>&1'"'"''
ok: [192.168.1.7] => {"changed": false, "msg": "", "rc": 0, "results": ["http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm: Nothing to do"]}
TASK: [Starting nginx service] ************************************************
<192.168.1.7> ESTABLISH CONNECTION FOR USER: root
<192.168.1.7> REMOTE_MODULE service name=nginx state=started
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1440146582.22-244037760484684 && echo $HOME/.ansible/tmp/ansible-tmp-1440146582.22-244037760484684'
<192.168.1.7> PUT /tmp/tmpl7NIQY TO /root/.ansible/tmp/ansible-tmp-1440146582.22-244037760484684/service
<192.168.1.7> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 192.168.1.7 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=hhzkesasgpvhlwbmgckouzbsnovgzpmr] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-hhzkesasgpvhlwbmgckouzbsnovgzpmr; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1440146582.22-244037760484684/service; rm -rf /root/.ansible/tmp/ansible-tmp-1440146582.22-244037760484684/ >/dev/null 2>&1'"'"''
failed: [192.168.1.7] => {"failed": true}
msg: no service or tool found for: nginx
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/root/setup_nginx.retry
192.168.1.7 : ok=3 changed=0 unreachable=0 failed=1
답변1
나는 nginx-release-centos-6-0.el6.ngx.noarch.rpm
이것이 아치 독립 지원 패키지이고 완전한 nginx 설치에는 충분하지 않다고 생각합니다. 또한 다음 위치에 있는 아치 관련 패키지를 설치해야 합니다.i386또는x86_64목차.
다음과 같이 yum 저장소를 설정하는 것이 좋습니다.공식 설치 지침:
---
- hosts: testing
tasks:
- name: Setting up nginx repository
copy:
dest: /etc/yum.repos.d/nginx.repo
content: |
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
sudo: yes
- name: Install nginx package
yum: name=nginx state=present
sudo: yes
- name: Starting nginx service
service: name=nginx state=started
sudo: yes
답변2
nginx-release-centos-6-0.el6.ngx.noarch.rpm은 nginx 패키지가 아니며 nginx 저장소 패키지입니다. 설치하면 nginx 저장소가 생성됩니다. 따라서 실제 nginx를 설치하려면 하나 이상의 작업을 완료해야 합니다.
yum: name=nginx state=latest
패키지 설명을 볼 수 있습니다.
rpm -qip nginx-release-centos-6-0.el6.ngx.noarch.rpm
...
요약: nginx repo 구성 및 pgp 공개 키