
ansible
杨嚣
这个作者很懒,什么都没留下…
展开
-
ansible使用3--模块的概念
模块的概念1 笼统查看所有模块说明[root@self1-centos7-2 11:06:16 /etc/ansible]#ansible-doc -la10_server Manage A10 Networks AX/SoftAX/Thunder/vThunder devices' server obj...原创 2019-06-13 13:48:54 · 146 阅读 · 0 评论 -
ansible使用12--handler
修改nginx的配置文件,某个server的端口从8080改成8088,修改配置后重启nginx(尽管nginx读入新配置可用nginx -s reload,但这里作为示例执行重启)。剧本如下:---- hosts: self1-1 remote_user: root tasks: - name: Modify the configuration lineinfile: ...转载 2019-06-16 18:04:23 · 349 阅读 · 0 评论 -
ansible使用11--playbook初步2
写法1 --- - hosts: self1-1 self2-1 remote_user: root task: - name: ping the host ping: - name: touch test.txt file: path: /test ...转载 2019-06-16 18:02:37 · 111 阅读 · 0 评论 -
ansible使用10--playbook初步
以下均学习于朱双印先生博客ansible playbook初步工作场景,三条命令组成,下载nginx,并运行[root@self1-centos7-2 20:50:12 ~]#ansible self1-1 -m yum_repository -a 'name=aliepel description="aliyum" file=aliyum baseurl=https://mirrors.a...转载 2019-06-16 18:00:00 · 213 阅读 · 0 评论 -
ansible使用9--包管理模块
包管理模块yum_repository模块yum仓库管理name: required仓库的唯一id,也就是“.repo”配置文件中每个仓库对印的中括号内的仓库IDbaseurl: yum仓库urldescription: 仓库注释file: 设置仓库配置文件名称,xxxx.repoenabled: 是否激活yum源gpgcheck: 是否开启包验证gpgcakey: 指...原创 2019-06-15 16:41:48 · 487 阅读 · 0 评论 -
ansible使用8--系统类模块2
系统模块user模块管理主机上的用户[root@self1-centos7-2 19:24:40 ~]#ansible-doc -s user- name: Manage user accounts user: append: # yes,追加附加组 authorization: # Sets the authori...原创 2019-06-15 16:03:47 · 195 阅读 · 0 评论 -
ansible使用7--系统类模块
系统类模块cron模块远程管理主机的计划任务,相当于crontab命令服务脚本名称:/etc/init.d/crond主要设置文件全局配置文件,位于文件:/etc/crontab系统默认的设置,位于目录:/etc/cron.*/用户定义的设置,位于文件:/var/spool/cron/用户名5 1 * * * echo test 每天1点5分1 1 */3 * * echo t...原创 2019-06-15 14:50:19 · 176 阅读 · 0 评论 -
ansible使用6--命令类模块
command模块在远程主机上执行命令,但不会经过远程主机shell处理,因此重定向、管道等操作会失效[centos@self1-centos7-2 ~]$ ansible-doc -s command- name: Execute commands on targets command: argv: # Passes the command...原创 2019-06-14 22:31:50 · 285 阅读 · 0 评论 -
ansible使用5--文件操作的模块2
5、find模块[centos@self1-centos7-2 ~]$ ansible-doc -s find- name: Return a list of files based on specific criteria find: age: # 根据时间范围查找。age=-3d seconds, minutes, hours, d...原创 2019-06-14 21:35:54 · 180 阅读 · 0 评论 -
ansible使用4--文件操作的模块
4、文件操作模块1、copy模块 将管理主机上的文件拷贝到远程主机[root@self1-centos7-2 11:28:42 /test/self2-1/etc]#ansible-doc -s copy- name: Copy files to remote locations copy: backup: # 当远程已经存在同名文件时,对远程文件备份,然后写入 新文件...原创 2019-06-13 16:49:18 · 1177 阅读 · 0 评论 -
ansible使用13--tags的用法
一个很长的playbook,其中有很多任务,只想执行其中一部分任务或一类任务,可以借助于打标,即tags示例,给每个任务一个tag---- hosts: self1-1 remote_user: root tasks: - name: task1 file: path: /testdir/t1 state: touch tags: t1,t...转载 2019-06-16 18:06:45 · 280 阅读 · 0 评论