首页 > 其他 > 详细

ansible 变量定义和引用

时间:2018-11-04 17:52:20      阅读:127      评论:0      收藏:0      [点我收藏+]

cat /etc/ansible/hosts

[nodes]
10.2.1.232 key=232
10.2.1.43 key=43

cat debug.yaml

---
- name: test how to use command module
hosts: nodes
remote_user: root
gather_facts: false
vars:
- content: ‘20181104‘
tasks:
- name: create a file
shell: "echo {{key}} >/root/{{inventory_hostname}}.txt"

结果:

cat  10.2.1.232.txt

232

2.gather_facts


- name: gather_facts of each host
  template: src=/root/nginx.conf dest=/root/nginx.conf

 cat /root/nginx.conf 

worker_processes {{  ansible_processor_cores }};

 \\获取ansible的要调用的相关函数

ansible 变量定义和引用

原文:https://www.cnblogs.com/hixiaowei/p/9904550.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!