我是使用 ansible 的新手,我正在尝试设置一个简单的 Hello World 剧本。到目前为止,我的一切都在互相交谈,但我似乎无法自动化 nginx 安装。我尝试了几种变体,但似乎找不到任何关于 yum 使用 ansible 安装 nginx 的文档。
我的剧本如下所示:(抱歉格式化)。它贯穿 EPEL 发行版安装,似乎永远挂在 nginx 安装上。
---
- hosts: webserver
tasks:
- name: Install EPEL release for nginx
yum: name=epel-release state=present
- name: Install nginx web server
yum: name=nginx state=installed update_cache=true
notify:
- start nginx
- name: Upload the default index.html file
copy: src=html_files/index.html dest=/usr/share/nginx/www/ mode=0644
handlers:
- name: start nginx
service: name=nginx enables=yes state=started
任何帮助将不胜感激。
如果我将第 8 行更改为:
yum: name=http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm state=present
它运行良好。
失败任务的剧本输出:
TASK: [Install nginx web server] **********************************************
<54.67.19.159> ESTABLISH CONNECTION FOR USER: root
<54.67.19.159> REMOTE_MODULE yum name=nginx state=latest update_cache=true
<54.67.19.159> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/username/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="/Users/username/.ssh/pemfile.pem" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 54.67.19.159 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1427534955.48-246337214944853 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1427534955.48-246337214944853 && echo $HOME/.ansible/tmp/ansible-tmp-1427534955.48-246337214944853'
<54.67.19.159> PUT /var/folders/l0/5f3qkrxd1sn976dzb5sfkk640000gn/T/tmpczLCV7 TO /root/.ansible/tmp/ansible-tmp-1427534955.48-246337214944853/yum
<54.67.19.159> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/username/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="/Users/username/.ssh/pemfile.pem" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 54.67.19.159 /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python -tt /root/.ansible/tmp/ansible-tmp-1427534955.48-246337214944853/yum; rm -rf /root/.ansible/tmp/ansible-tmp-1427534955.48-246337214944853/ >/dev/null 2>&1'