ansible-doc -l #列出所有模块 [root@workstation ~]# ansible-doc yum #列出 yum 的用法和示例 [root@workstation ~]# ansible-doc -s yum #终端中输出 yum 模块中各参数的用法 ###PLAYBOOK 语法变化 ###yaml 注释 #This is a YAML comment some data # This is also a YAML comment ###yaml 字...
2、module:arguments 注意:shell和command模块后面直接跟命令,而非key=value类的参数列表 1、某任务的状态在运行后为changed时,可通过"notify"通知给相应的handlers 2、任务可以通过"tags"打标签,而后可在ansible-playbook命令上使用-t指定进行调用 运行playbook的方式: 1、测试: ansible-playbook --syntax-check 只检...
yum 模块:用于在 CentOS 和 Red Hat 等系统上安装、升级和删除软件包。- name: Install a software package yum:name: nginx state: present - name: Remove a software package yum:name: nginx state: absent template 模块:用于在远程主机上基于模板文件生成配置文件。- name: Generate a configuration file...
or url had to be installed or removed together. In1.9.2this was fixed so that packages are installedinoneyumtransaction. However,ifone of the packages adds a newyumrepository that the other packages come from (such as epel-release)thenthat package needs to be installedina separate task. This...
(3)编写mysql模块 vim/etc/ansible/roles/mysql/tasks/main.yml-name:installmysqlyum:name={{pkg}}state=latest-name:startmysqlservice:enabled=truename={{svc}}state=startedvim/etc/ansible/roles/mysql/vars/main.ymlpkg:-mariadb-mariadb-server-svc:mariadb ...
# 定义任务名,非必须,根据实际任务命名 file: # 使用的模块 path: /etc/abc # 模块的动作 state: directory owner: www group: www# 例2:安装部署nginxvim nginx.yaml - hosts: web_grouptasks:- name: 安装nginx yum: name=nginx state=present- name: 复制nginx配置文件 co...
1、Playbook常用的模块-ping Ping检查指定节点机器是否还能联通,用法很简单,不涉及参数主机,如果在线则回复pong。 2、Playbook常用模块-yum Yum模块可以用于在服务器上安装特定软件 3、Playbook常用模块-pip Pip模块可以用于安装一些python依赖 4、Playbook常用模块-copy ...
一:Playbook剧本 play:定义的是主机的角色 task:定义的是具体执行的任务 image.png 1.1 使用之前的ansible模块组成playbook剧本安装rsync [root@m01-61cxy_shell]# vim rsync_server_install.yaml-hosts:backup tasks:-name:01-installed rsyncd yum:name=rsync state=installed-name:02-copy file ...
yum: name=httpd #调用yum模块安装httpd服务 - name: start httpd #同样是描述信息 service: name=httpd state=started enabled=yes #调用service模块启动httpd服务并设置开机自启 [root@ayunw ansible-project]# cat copy_files.yml --- - hosts: dbsrvs ...
yum模块: 目的:在指定节点上安装 apache 服务 命令:ansible all -m yum -a “state=present name=httpd” state=latest=>>安装最新版本 service模块: 目的:启动指定节点上的 httpd 服务,并让其开机自启动 命令:ansible 10.1.1.113 -m service -a ‘name=httpd state=restarted enabled=yes’ ...