Serviço nginx Ansible no CentOS 6.7

0

Estou tentando instalar e iniciar o nginx na minha caixa de teste do CentOS 6.7.

Meu manual de jogo

---
- 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

e o que eu recebi:

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   

É bug ou estou errado no playbook? Obrigado.

adicionado

Parece que falha na tarefa "Iniciando o serviço 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  
    
por user129494 20.08.2015 / 17:21

2 respostas

1

Eu acho que nginx-release-centos-6-0.el6.ngx.noarch.rpm é um pacote de suporte independente do arco e é insuficiente para a instalação completa do nginx. Você também precisa instalar o pacote específico do arco encontrado em i386 ou x86_64 dirs.

Eu recomendo que você configure o repositório do yum com base na instrução de instalação oficial :

---
- 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
    
por 20.08.2015 / 22:24
0

nginx-release-centos-6-0.el6.ngx.noarch.rpm não é nginx package, é nginx repository package. Quando você instalá-lo, ele criará o repositório nginx. Então você precisa de mais uma tarefa para instalar o nginx real:

yum: name=nginx state=latest

Você pode verificar a descrição do pacote:

rpm -qip nginx-release-centos-6-0.el6.ngx.noarch.rpm

...

Summary : nginx repo configuration and pgp public keys

    
por 21.08.2015 / 12:54