Ansible学习笔记9

yum_repository模块:

yum_repository模块用于配置yum仓库的。

测试下:

bash 复制代码
[root@localhost ~]# ansible group1 -m yum_repository -a "name=local description=localyum baseurl=file:///mnt/ enabled=yes gpgcheck=no"
192.168.17.106 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "repo": "local",
    "state": "present"
}
192.168.17.105 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "repo": "local",
    "state": "present"
}

检查:

bash 复制代码
[root@agent1 yum.repos.d]# ll
total 52
-rw-r--r-- 1 root root 1664 Aug 30 13:06 CentOS-Base.repo
-rw-r--r-- 1 root root 1309 Aug 30 13:06 CentOS-CR.repo
-rw-r--r-- 1 root root  649 Aug 30 13:06 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root  314 Aug 30 13:06 CentOS-fasttrack.repo
-rw-r--r-- 1 root root  630 Aug 30 13:06 CentOS-Media.repo
-rw-r--r-- 1 root root 1331 Aug 30 13:06 CentOS-Sources.repo
-rw-r--r-- 1 root root 8515 Aug 30 13:06 CentOS-Vault.repo
-rw-r--r-- 1 root root  616 Aug 30 13:06 CentOS-x86_64-kernel.repo
-rw-r--r-- 1 root root  951 Aug 30 13:06 epel.repo
-rw-r--r-- 1 root root 1050 Aug 30 13:06 epel-testing.repo
-rw-r--r-- 1 root root   73 Aug 30 15:04 local.repo
[root@agent1 yum.repos.d]# cat local.repo
[local]
baseurl = file:///mnt/
enabled = 1
gpgcheck = 0
name = localyum

yum模块(重点):

yum模块用于使用yum命令来实现软件包的安装与卸载。

使用yum安装一个软件(前提:group1的yum配置都已经OK)

检查agent机器,看到vsftpd都已经安装成功。

使用yum模块安装httpd、httpd-devel,state=latest表示安装的最新版本。

可以检查到安装进度:

检查各个agent机器,发现httpd都已经安装。

到agent1机器上检查,看到httpd已经卸载。

bash 复制代码
[root@agent1 yum.repos.d]# rpm -ql httpd
package httpd is not installed

Service模块(重点):

启动vsftpd,并设置为开机自动启动。

停止vsftpd服务,然后关闭开机自动启动。

配置这块内容,就直接用copy模块,将配置文件复制过去。

相关推荐
一切皆文件linux15 小时前
网站集群批量管理-密钥认证与Ansible模块
ansible
让美好继续发生2 天前
ansible学习
学习·ansible
有谁看见我的剑了?2 天前
ansible学习之 Facts
ansible
peanutfish2 天前
Chapter 4 RH294 RHEL Automation with Ansible
linux·ansible·yaml
henan程序媛3 天前
jenkins项目发布基础
运维·gitlab·ansible·jenkins
pyliumy4 天前
ansible 配置
大数据·ansible
运维小白。。4 天前
自动化运维工具 Ansible
运维·自动化·ansible
weixin_438197385 天前
ansible之playbook\shell\script模块远程自动安装nginx
linux·服务器·ansible
peanutfish5 天前
Chapter 5 RH294 RHEL Automation with Ansible
linux·ansible·yaml
人类群星闪耀时5 天前
自动化运维的利器:Ansible、Puppet和Chef详解
运维·自动化·ansible