ansible 配置变量

来源:互联网 发布:网络连接忘记账号密码 编辑:程序博客网 时间:2024/06/05 17:53
[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#lsabc.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 -ltrtotal 4-rwxrwxrwx 1 mqm mqm 84 Oct 11 00:33 abc.efg.txt

原创粉丝点击