1. ansible-playbook
  1)ansible-playbook的语法检测

1 [root@test-1 bin]# ansible-playbook --syntax-check nginx_tags.yaml
2
3 playbook: nginx_tags.yaml

2. ansible-debug打印实例
  1)案例

1 ---
2 - hosts:webservers
3 tasks:
4 - debug:
5 msg: {{group_names}} #打印ansible的host组
6 - debug:
7 msg: {{inventory_hostname}} #打印详细的host主机
8 - debug:
9 msg: {{ansible_hostname}} #配合gather_facts: yes 开启收集系统信息

3. ansible-debug使用案例
  1) ansible-debug案例调试

 1 [root@test-1 bin]# vim nginx_debug.yaml
2 [root@test-1 bin]# cat nginx_debug.yaml
3 - hosts: web1
4 remote_user: root
5 gather_facts: no #禁止收集系统信息
6 vars:
7 hello: Ansible
8
9 tasks:
10 - name: Add repo
11 yum_repository:
12 name: nginx
13 description: nginx repo
14 baseurl: http://nginx.org/packages/centos/7/$basearch/
15 gpgcheck: no
16 enabled: 1
17 - name: Install nginx
18 yum:
19 name: nginx
20 state: latest
21 - name: Copy nginx configuration file
22 copy:
23 src: /ansible/nginx/conf/site.conf
24 dest: /etc/nginx/conf.d/site.conf
25 - name: Start nginx
26 service:
27 name: nginx
28 state: started
29 - name: Create wwwroot directory
30 file:
31 dest: /var/www/html
32 state: directory
33 - name: Create test page index.html
34 debug: #开启debug模式
35 msg: "123 {{ inventory_hostname }}"
36 tags:
37 - debug
38
39 执行
40 [root@test-1 bin]# ansible-playbook nginx_debug.yaml --tags debug
41
42 PLAY [web1] ************************************************************************************************************************************
43
44 TASK [Create test page index.html] *************************************************************************************************************
45 ok: [192.168.200.132] => {
46 "msg": "123 192.168.200.132"
47 }
48 ok: [192.168.200.133] => {
49 "msg": "123 192.168.200.133"
50 }
51
52 PLAY RECAP *************************************************************************************************************************************
53 192.168.200.132 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
54 192.168.200.133 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

最新文章

  1. 【python】函数之内置函数
  2. 并查集(加权) LA 4487 Exclusive-OR
  3. 从Lumia退役看为什么WP走向没落
  4. codeforces 590C C. Three States(bfs+连通块之间的最短距离)
  5. Android查询:模拟键盘鼠标事件(adb shell 实现)
  6. mlock家族:锁定物理内存
  7. ios paper for facebook 使用第三方库
  8. 【POJ2761】【fhq treap】A Simple Problem with Integers
  9. NSSet与NSArray区别
  10. 笔记--cocos2d-x 3.0 环境搭建
  11. 微信web开发者工具使用
  12. Spring Boot + Dubbo 可运行的例子源码-实现服务注册和远程调用
  13. ORALCE PL/SQL学习笔记
  14. C# join子句
  15. 文件操作(File类等)API摘要
  16. oracle的PDB启动
  17. 使用scp命令在多个Linux系统间进行文件复制
  18. Mac键盘按键符号
  19. mui---取消掉默认加载框
  20. Cracking The Coding Interview3.3

热门文章

  1. CTF线下awd攻防文件监控脚本
  2. Mysql执行计划(大章)
  3. Mybatis源码学习第六天(核心流程分析)之Executor分析
  4. 三年前买的T440p目前淘宝二手价2300左右
  5. Ubuntu 安装配置 WordPress5.4.2
  6. Vue 侦听器 watch
  7. end的用法——print中加end=可以不换行展示
  8. js之按钮切换
  9. Codeforces1131G Most Dangerous Shark
  10. k8s数据管理(八)