我正在尝试在 OS X 上使用 Ansible 2.1.1.0 获得一些非常基本的东西。
我的目标都是 Ubuntu 16.04,所以我要做的第一件事就是让它安装 python2.7,因为没有它,即使 'ping' 也无法工作。
我在以下位置设置了这样的库存servers
:
[dbservers]
192.168.x.x set_hostname=db
[webservers]
[servers:children]
dbservers
webservers
Run Code Online (Sandbox Code Playgroud)
这是我的游戏init.yml
:
---
- hosts: servers
gather_facts: False
become: yes
tasks:
- name: apt-get update
raw: /usr/bin/apt-get update -qq
- name: Install python 2.7
raw: test -e /usr/bin/python || /usr/bin/apt-get install -q -y python2.7 python-simplejson
Run Code Online (Sandbox Code Playgroud)
我通过指定dbservers
组来检查它是否选择了正确的主机,该组是servers
(无论如何只有 1 个)的一个子集,这对我来说是正确的:
# ansible dbservers -i servers --list-hosts
hosts (1):
192.168.x.x
Run Code Online (Sandbox Code Playgroud)
我正在运行的命令是这样的:
# ansible dbservers -i servers init.yml
Run Code Online (Sandbox Code Playgroud)
那是我收到错误的时候ERROR! Missing target hosts
。我不明白它怎么可以同时拥有主机和没有主机!我究竟做错了什么?
您正在尝试playbook
使用该ansible
命令运行 a 。该ansible
命令是用于add-hoc
命令。
尝试使用ansible-playbook
命令执行您的剧本:
ansible-playbook -i servers init.yml
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
24170 次 |
最近记录: |