官术网_书友最值得收藏!

A very simple playbook

To demonstrate how playbooks work, the following example will show a small playbook that also makes use of the variables we configured earlier:

- hosts: mon1 osd1
tasks:
- name: Echo Variables
debug: msg="I am a {{ a_variable }}"

Now run the playbook. Note the command to run a playbook that differs from running ad hoc Ansible commands:

    $ ansible-playbook /etc/ansible/playbook.yml

The preceding command gives the following output:

The output shows the playbook being executed on both mon1 and osd1 as they are in groups, which are children of the parent group ceph. Also, note how the output is different between the two servers as they are picking up the variables that you set earlier in the group_vars directory.

Finally, the last couple of lines show the overall run status of the playbook run. You can now destroy your Vagrant environment again, ready for the next section:

    vagrant destroy --force

This concludes the introduction to Ansible, but it is not a complete guide. It's recommended that you should explore other resources to gain a more in-depth knowledge of Ansible before using it in a production environment.

主站蜘蛛池模板: 益阳市| 修水县| 龙州县| 紫金县| 夹江县| 中西区| 巴彦县| 渑池县| 凯里市| 平和县| 阿巴嘎旗| 望城县| 恭城| 怀来县| 湄潭县| 日照市| 娄底市| 浠水县| 九江县| 朝阳区| 洛川县| 兴安县| 江西省| 深水埗区| 寿宁县| 青浦区| 南涧| 江阴市| 宜君县| 瓦房店市| 江陵县| 高要市| 巍山| 稷山县| 平潭县| 陇南市| 交城县| 原阳县| 屯昌县| 镇安县| 宝丰县|