zoukankan      html  css  js  c++  java
  • ansible 配置变量

    [root@node01 ansible]# cat playbook.yml
    - hosts: database
      vars:
        http: abc
        address: efg
      tasks:
      - name: Copy ansible inventory file to client
        copy: src=/etc/ansible/hosts dest=/etc/ansible/{{http}}.txt
                owner=mqm group=mqm mode=777
    [root@node01 ansible]# ansible-playbook  playbook.yml
    [DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a generic framework . This feature will be removed in version 2.8. Deprecation warnings can be disabled by 
    setting deprecation_warnings=False in ansible.cfg.
    
    PLAY [database] *******************************************************************************************************************************************************************************
    
    TASK [Gathering Facts] ************************************************************************************************************************************************************************
    ok: [192.168.137.3]
    
    TASK [Copy ansible inventory file to client] **************************************************************************************************************************************************
    changed: [192.168.137.3]
    
    PLAY RECAP ************************************************************************************************************************************************************************************
    192.168.137.3              : ok=2    changed=1    unreachable=0    failed=0   
    
    node2:/etc/ansible#ls
    abc.txt
    
    
    
    [root@node01 ansible]# cat playbook.yml
    - hosts: database
      vars:
        http: abc
        address: efg
      tasks:
      - name: Copy ansible inventory file to client
        copy: src=/etc/ansible/hosts dest=/etc/ansible/{{http}}.{{address}}.txt
                owner=mqm group=mqm mode=777
    [root@node01 ansible]# ansible-playbook  playbook.yml
    [DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a generic framework . This feature will be removed in version 2.8. Deprecation warnings can be disabled by 
    setting deprecation_warnings=False in ansible.cfg.
    
    PLAY [database] *******************************************************************************************************************************************************************************
    
    TASK [Gathering Facts] ************************************************************************************************************************************************************************
    ok: [192.168.137.3]
    
    TASK [Copy ansible inventory file to client] **************************************************************************************************************************************************
    changed: [192.168.137.3]
    
    PLAY RECAP ************************************************************************************************************************************************************************************
    192.168.137.3              : ok=2    changed=1    unreachable=0    failed=0   
    
    
    
    node2:/etc/ansible#ls -ltr
    total 4
    -rwxrwxrwx 1 mqm mqm 84 Oct 11 00:33 abc.efg.txt

  • 相关阅读:
    【递推】【HDU 2073】无限的路 (找规律)
    【省赛】山东省第七届ACM省赛(部分水题)
    【思维】牛客练习赛16 B-漂亮的树
    【搜索】牛客练习赛16 C-任意点 (类似求联通块)
    输入输出
    Python入门——运行python的两种方式&变量&常量
    编程语言分类
    What is an Operating System?
    计算机硬件&编程基础
    《SPA设计与架构》之认识SPA
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349475.html
Copyright © 2011-2022 走看看