这是我写的Ansible攻略的一部分。
- name: Check OS Version
fail:
msg: "{{ ansible_distribution }} {{ ansible_distribution_version }} is not compatible with this role"
when: ansible_distribution != 'Ubuntu' and ansible_distribution_release != 'trusty'
我在一台ubuntu/trusty的Vagrant机器上运行
我只是通过使用Ansible提供的例子来学习Ansible。
当我试图在剧本的开头放一条调试消息时,我得到了如下所示的错误。
vagrant@packer-debian-7:~/ansible-examples-master/lamp_simple$ ansible-playbook -i hosts site.yml --private-key=~/.ssh/google_compute_engine -vvvv
ERROR: debug is not a legal parameter at this level in an Ansible Playbook
site.yml
---
#
使用Ansible ansible 2.4.2.0,我只想从主剧本(main.yml)中运行一个特定的剧本
---
# main playbook for cluster deployment
# initial configuration of OS same for all hosts
- name: Cluster Deployer playbook
hosts: all
roles:
- { role: common, tags: ['initial_config'] }
# configuration specific for loadb
我正在学习Ansible,但我对在playbook中何时使用连字符以及何时不使用连字符感到困惑。据我所知,在Ansible中,list使用连字符。
例如,
--- # my first playbook
- hosts: webservers ( why did we use hyphen here it is not a list)
tasks:
- name: installing httpd
yum: name=httpd state=installed ( why we shouldn't use hy
我已经编写了一个行动手册,用于在resolv.conf中添加一个条目并添加一个新用户。我在not present in target system中指定的组,但是我在模拟运行(使用--check)选项时没有得到错误,而是在实际运行中得到了错误。
[root@ansible-controller ansible-test-project]# ansible-playbook lineinfile-playbook.yaml -i inventory.txt --check
PLAY [Add a new nameserver and webuser] ********************