随笔分类 - ansible-自动化运维
摘要:1. Ansible-playbook 同一组相同主机 使用hostname作为ansible playbook的inventory entry key,这样这个inventory就可以执行两次。简单粗暴的解决问题。真是太棒了 [nova-compute] my_compute_cluster an
阅读全文
摘要:1.ansible的playbook - name: a template example hosts: frame remote_user: root tasks: - name: max login try count shell: egrep -i 'MaxAuthTries' /etc/ss
阅读全文
摘要:1.通过debug模块去确认返回结果的数据结构 获取Task任务结果 - name: check nginx syntax shell: /usr/sbin/nginx -t register: nginxsyntax 通过debug模块去确认返回结果的数据结构 - name: print ngin
阅读全文
摘要:1.访问变量文件 - hosts: frame remote_user: root gather_facts: no vars_files: - /testdir/ansible/testfile.txt tasks: - debug: msg: "{{key_1}}" 变量文件: [root@fr
阅读全文
摘要:1.async参数值:代表了这个任务执行时间的上限值。即任务执行所用时间如果超出这个时间,则认为任务失败。此参数若未设置,则为同步执行 2.poll参数值:代表了任务异步执行时轮询的时间间隔。 loop循环使用 - hosts: frame tasks: - name: yum install vs
阅读全文
摘要:0.禁止root登陆1.用sudo的用户登陆2.执行root的权限 3.cat /etc/ansible/hosts # Ex 2: A collection of hosts belonging to the 'webservers' group [test] 10.0.0.3 ansible_s
阅读全文
摘要:1.用ansible做安全自查,形成报告 - hosts: huidu tasks: - name: register shell result to variable shell: ps aux|grep 18086|grep -v 'grep'|wc -l register: host_ps -
阅读全文
摘要:1.整体文件框架 2.调用主机和目标任务 [root@ks-allinone myansible_roles]# cat elasticsearch_service.yml - hosts: huidu roles: - role: elasticsearch 3.es配置 [root@ks-all
阅读全文
摘要:1.挂载 # mkdir /mnt/cdrom # mount /mnt/CentOS-7.0-1406-x86_64-DVD.iso /mnt/cdrom/ 2.配置 # touch CentOS-ISO.repo # cat CentOS-ISO.repo [base] name=CentOS-
阅读全文
摘要:1.文件架构 2. test3.j2的内容 3. jinj2_test.yml的内容 4.运行的结果 参考:https://blog.csdn.net/qqhappy8/article/details/79217380 https://blog.51cto.com/linuxg/1788574 ##
阅读全文
摘要:1.roles意为角色,主要用于封装playbook实现复用性。在ansible中,roles通过文件的组织结构来展现。
阅读全文
摘要:1.开启SSH长连接 ssh_args = -C -o ControlMaster=auto -o ControlPersist=1d \\连接保持一天 2.开启pipelining ansible执行tasks的过程: 1>ansible根据选择的模块生成临时的Python脚本 2>他将所生成的脚
阅读全文
摘要:cat /etc/ansible/hosts [nodes]10.2.1.232 key=23210.2.1.43 key=43 cat debug.yaml name: test how to use command module hosts: nodes remote_user: root ga
阅读全文
摘要:1. ansible 10.0.0.1 -m raw -a "date" -u www 2.在ansible的主机配置文件中指定ssh_uservi/etc/ansible/hosts10.0.0.1 ansible_ssh_user=www 3.特殊符号- 用shell模块 ansible tes
阅读全文
摘要:yet another markup language -- 另外的一种标记语言 yaml 语法: 序列:同一个类型的数据有多个,用"-" 来区分,叫序列 映射:价值对,用":"来表示 经典例子:name: jame smithssex: maleage: 28spource: name: jane
阅读全文
摘要:寻找/etc/ 名为"hosts" 递归查找 ansible webserver -m find -a ' path=/etc/ file_type=any recurse=yes pattern="hosts"' /etc/下包含xiaowei的文件 ansible webserver -m fi
阅读全文
摘要:在分发配置文件的时候,我用命令ansible big_hosthub -m copy -a "src=/home/clouder/deploy-conf.xml dest=/home/clouder/deploy-conf.xml force=yes" 不起作用,配置文件还是原来的文件,即使使用了f
阅读全文
摘要:目标效果: [root@ansible ~]# python query.py --list{ "test": [ "10.1.2.1", "10.1.2.2" ], "www": [ "1.2.3.4", "5.6.7.8" ]} [root@ansible ~]# python query.py
阅读全文
摘要:defaultdict 的例子 使用list作为default_factory,他很容易的将一个以键值形式表现的序列分组成一个字典列表
阅读全文
摘要:作者:匿名用户链接:https://www.zhihu.com/question/46973549/answer/103805810来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 定义类的时候,若是添加__init__方法,那么在创建类的实例的时候,实例会自动调用这个
阅读全文