码迷,mamicode.com
首页 >  
搜索关键字:ansible 常用模块    ( 3327个结果
ansible进阶循环
通过item和with_items对重复操作进行循环执行示例:hosts:jack6_1remote_user:rootgather_facts:notasks:name:touchfilefile:path:"{{item}}"state:touchwith_items:"a""b""c"在jack6_1主机上创建三
分类:其他好文   时间:2020-09-17 17:20:16    阅读次数:39
ansible的循环二
with_items遍历列表中每个元素,包括嵌套列表with_list将嵌套列表作为整体元素遍历with_together将多个列表中的子列表元素,一起输出,不成对则null补位示例:hosts:jack6_1remote_user:rootgather_facts:notasks:debug:msg:"{{item}}"with_items:[1,2,3][a,b]debug
分类:其他好文   时间:2020-09-17 17:19:57    阅读次数:31
ansible循环四
with_indexed_items示例:hosts:jack6_1remote_user:rootgather_facts:notasks:debug:msg:"{{item}}"with_indexed_items:[t1,t2][t3,[t4,t5]][t6]输出结果如下:[root@jack7-1work]#ansible-playbook--syntax-checki
分类:其他好文   时间:2020-09-17 17:19:41    阅读次数:32
ansible循环四
with_indexed_items示例:hosts:jack6_1remote_user:rootgather_facts:notasks:debug:msg:"{{item}}"with_indexed_items:[t1,t2][t3,[t4,t5]][t6]输出结果如下:[root@jack7-1work]#ansible-playbook--syntax-checki
分类:其他好文   时间:2020-09-17 17:19:20    阅读次数:33
ansible循环三
with_nested采用笛卡尔乘积方式,将多个嵌套列表中的元素交叉组合示例:创建多个目录及子目录mkdir-p/testdir/{a,b,c}/{1,2}ansible剧本如下:hosts:jack6_1remote_user:rootgather_facts:notasks:file:path:"/testdir"state:directoryfile:path:"
分类:其他好文   时间:2020-09-17 16:54:16    阅读次数:24
ansible模块register/vars
register注册变量可以将输出信息作为变量值示例:[root@jack7-1work]#catregister.ymlhosts:PCremote_user:roottasks:name:testshellshell:"echotest>/root/test"register:testvar==================>将shell输出的结果赋值给tes
分类:其他好文   时间:2020-09-17 16:02:37    阅读次数:28
ansible剧本playbook
格式.yml|.yaml---======>剧本开头-hosts:jack7======>指定主机或主机组remote_user:root====>客户端执行用户tasks:=========>任务标记-name:FIRSTPLAYBOOK===>PLAY名称fetch:=======>调用的模块src:/tmp/test=======>模块的参数及值de
分类:其他好文   时间:2020-09-17 12:49:53    阅读次数:26
ansible内部handlers
handlers和tasks同级别调用handlers,在tasks的下级notify调用notify可以指定handlers的name或listenmeta:flush_handlers指定tasks任务结束就调用handlers示例如下[root@jack7-1ansible]#cattest7.ymlhosts:PAremote_user:roottasks:name:checkapache
分类:其他好文   时间:2020-09-17 12:47:12    阅读次数:29
ansible变量vars/vars_files
对于重复使用而且复杂的参数值,可以定义变量引用,便于管理和修改,也可以创建文件存放变量,引用变量文件即可示例如下[root@jack7-1ansible]#tree..├──ansible.cfg├──backup│└──backup.sh├──hosts├──roles├──vars============>存放变量的目录│└──httpd.yml=========>存放变量的文件└
分类:其他好文   时间:2020-09-17 12:28:04    阅读次数:25
ansible模块user/group
user模块user模块可以帮助我们管理远程主机上的用户,比如创建用户、修改用户、删除用户、为用户创建密钥对等操作。此处我们介绍一些user模块的常用参数,你可以先对这些参数有一个大概了解,然后再看小示例。name参数:必须参数,用于指定要操作的用户名称,可以使用别名user。group参数:此参数用于指定用户所在的基本组gourps参数:此参数用于指定用户所在的附加组,注意,如果说用户已经存在并
分类:其他好文   时间:2020-09-15 21:14:22    阅读次数:40
3327条   上一页 1 ... 6 7 8 9 10 ... 333 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!