---
#Execution command: ansible-playbook -i /root/zhangb/ansible/hosts t.yml --extra-vars "filename=play.txt filetype=pdf"
#ansible variables use
- hosts: c17
gather_facts: yes #Whether to execute the fact module
vars:
facolor: blue
vars_files: #File definition (there is a problem in this place)
- /data/mondev/1.yml
- /data/mondev/2.yml
vars_prompt: #Custom interactive parameters
- name: 'https_passphrase' #Saved parameter name
prompt: 'Key Passphrase'#Input prompt
private: no#Whether to hide plaintext
tasks:
- name: show hostname
debug:
msg: "hostname {{ ansible_nodename }}"
when: ansible_nodename is defined
- name: shell test#shell module chdir parameter usage
shell: more 1.txt chdir=/data/mondev/2/
- name: show args#Output all variables of the system, mainly fact static variables
debug:
var: hostvars[inventory_hostname]
verbosity: 4
- name: command run line#Register Result variable
shell: date
register: result
- name: show result #Print result variable
debug: var=result.stdout verbosity=4
- name: print vars1#Register multiple result variables
shell: ls
register: v_dirs
- name: print vars1_1# Variables Multiple result variables
shell: echo {{ item }}
with_items: v_dirs.stdout_lines
#same as with_items: v_dirs.stdout.split()
- name: print self-defind local fact #Print custom fact variables, the definition file is stored by default in /etc/ansible/facts.d/**.yml
debug: var=ansibl_local
- name: show command args#print command line arguments
debug: var='{{ filename }}'
- name: print self-defind vars#print global variable
debug: var='{{ facolor }}'
- name: print promt vars#Print custom input variables
debug: var='{{ https_passphrase }}'
43F.dianxinguangchang.zhongshanerlu.yuexiuqu.guangzhoushi,guangdongsheng
--2017-08-02