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

  • 相关阅读:
    数据库——事务
    数据库——连接池
    JDBC——使用jdbc操作时,如何提取数据的性能
    2019-06-26 The Eclipse executable launcher was unable to locate its companion launcher
    2019-06-24在windows下如何查看80端口占用情况?是被哪个进程占用
    2019-06-19_解决ActiveMQ访问出现503的错误
    2019-06-17 tomcat启动;zookeeper启动批处理
    2019-06-13记忆 长命令
    2019-06-13linux的vi编辑器中如何查找关键字
    2019-06-13-vim配色步骤
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349475.html
Copyright © 2011-2022 走看看