![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ansible
文章平均质量分 52
SnowRomance
这个作者很懒,什么都没留下…
展开
-
ansible 安装
特点: 1、不需要安装客户端,通过 sshd 通信 2、基于模块工作,模块可以由任何语言开发 3、不仅支持命令行使用模块,也支持 yaml 格式的 playbook 4、支持 sudo 5、有提供 UI www.ansible.com/tower 10台主机以内免费 6、开源UI https://github.com/alaxli/ansible_ui 文档 http://do原创 2016-05-06 16:27:34 · 253 阅读 · 0 评论 -
远程执行命令
1、修改配置文件 # vim /etc/ansible/hosts [testhosts] 127.0.0.1 192.168.32.105 2.执行 command 模块 ansible testhosts -m command -a 'w' ansible 127.0.0.1 -m command -a 'hostname' 3、报错缺少 libselinux-原创 2016-05-06 16:27:47 · 256 阅读 · 0 评论 -
各种功能
1、拷贝 ansible testhosts -m copy -a "src=/etc/ansible dest=/tmp/ansibletest owner=root group=root mode=0644" 2、脚本 首先分发脚本 ansible testhosts -m copy -a "src=/tmp/test.sh dest=/tmp/test.sh mode=0755"原创 2016-05-06 16:27:59 · 230 阅读 · 0 评论 -
playbook
使用 playbook 来创建一个文件 1、cd /etc/ansible 2、vim test.yml --- - hosts: testhosts remote_user: root tasks: - name: test_playbook shell: touch /tmp/test.txt 3、执行 ansible-playbook原创 2016-05-06 16:28:12 · 319 阅读 · 0 评论 -
playbook 循环
# vim loop.yml --- - name: loop_test hosts: testhosts user: root tasks: - name: change mode for files file: path=/tmp/{{ item }} mode=600 owner=root group=root with_i原创 2016-05-06 16:28:24 · 200 阅读 · 0 评论 -
play-book 判断
# vim when.yml --- - name: when_test hosts: testhosts user: root gather_facts: True tasks: - name: use when shell: touch /tmp/when.txt when: facter_ipaddress == "1原创 2016-05-06 16:28:37 · 310 阅读 · 0 评论 -
playbook handlers
# vim handlers.yml --- - name: handler_test hosts: testhosts user: root tasks: - name: copy file copy: src=/etc/passwd dest=/tmp/aaa.txt 当对方机器上有对应的文件的时候是不会调用 handlers原创 2016-05-06 16:28:52 · 452 阅读 · 0 评论 -
ansible 安装 nginx
1、首先安装一个 nginx ,打包 2、cd /etc/ansible 3、mkdir nginx_install 4、cd nginx_install 5、mkdir -p roles/{common,install}/{handlers,files,meta,tasks,templates,vars} roles 目录下有两个角色,common为一些准备操作,install 为安原创 2016-05-06 16:29:15 · 1672 阅读 · 0 评论 -
管理配置文件
1.cd /etc/ansible;mkdir nginx_config 2.cd nginx_config;mkdir roles;cd roles; 3.mkdir old new;cd new/ 4.mkdir vars files tasks handlers 5.将配置文件拷贝到对应的 files下 cp /usr/local/nginx/conf/nginx.conf fil原创 2016-05-06 16:29:33 · 299 阅读 · 0 评论