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模块,将配置文件复制过去。

相关推荐
tianyuanwo2 天前
Ansible自动化运维全解析:从设计哲学到实战演进
运维·自动化·ansible
哆啦A梦15882 天前
在golang中如何将已安装的依赖降级处理,比如:将 go-ansible/[email protected] 更换为 go-ansible/@v1.1.7
开发语言·golang·ansible
lifeng43213 天前
在 CentOS 上将 Ansible 项目推送到 GitHub 的完整指南
centos·github·ansible
运维成长记7 天前
ansible-playbook 进阶 接上一章内容
linux·服务器·ansible
半桶水专家8 天前
Ansible 配置Playbook文件格式、关键字和语法详解
ansible
遇见火星10 天前
Ansible模块——Ansible配置文件!
linux·git·ansible
安顾里11 天前
Ansible安装
linux·运维·自动化·ansible
爱莉希雅&&&13 天前
运维Linux之Ansible详解学习(更新中)
linux·运维·ansible
筑梦之路19 天前
centos 9 Kickstart + Ansible自动化部署 —— 筑梦之路
centos·自动化·ansible
遇见火星19 天前
Ansible模块——通过 URL 下载文件
ansible