zoukankan      html  css  js  c++  java
  • ansible-playbook调试

    转载于互联网

    检测 远程主机信息    ansible -i /XXXXX.hosts dev107 -m setup    

    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     开启收集系统信息
    - debug:
    var:inventory_hostname var=变量
    when:inventory_hostname //不需要{{ }}
    复制代码

    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
    register: result 33 - name: Create test page index.html 34 debug: #开启debug模式 35 msg: "123 {{ inventory_hostname }}" 36 tags: 37 - debug:var=result.stdout
    38
    debug:
    39 执行 40 [root@test-1 bin]# ansible-playbook -vvvv nginx_debug.yaml --tags debug //加入 -vvvv打印详细输出信息 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
  • 相关阅读:
    Could not resolve com.android.support:appcompat-v7:28.0.0 错误处理
    解决 Could not resolve com.android.tools.build:gradle:3.1.3
    https://maven.google.com 连接不上的解决办法(转)
    jquery操作select(取值,设置选中)
    django 使用 request 获取浏览器发送的参数
    jquery下载,实时更新jquery1.2到最新3.3.1所有版本下载
    myeclipse 8.5反编译插件失效
    再探java基础——对面向对象的理解(2)
    庖丁解牛FPPopover
    去大连
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/14770843.html
Copyright © 2011-2022 走看看