ansible模块--yum模块

网友投稿 1100 2022-10-10

ansible模块--yum模块

ansible模块--yum模块

state:installed 安装软件包 removed 卸载软件包disable_gpg_check=yes :取消密钥的认证update_cache=yes 更新缓存,需要在指定安装包时使用​​

1.确定被控端的yum本地源或者网络源

2.安装一个yum源

[root@ansible ~]# ansible mysql -m yum -a 'name=gcc state=installed'192.168.56.88 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "msg": "", "rc": 0, "results": [ "gcc-4.8.5-44.el7.x86_64 providing gcc is already installed" ]}[root@ansible ~]# ansible mysql -m yum -a 'name=g++ state=installed'192.168.56.88 | FAILED! => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "msg": "No package matching 'g++' found available, installed or updated", "rc": 126, "results": [ "No package matching 'g++' found available, installed or updated" ]}[root@ansible ~]# ansible mysql -m yum -a 'name=gcc state=installed'192.168.56.88 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "changes": { "installed": [ "gcc" ] }, "msg": "Warning: RPMDB altered outside of yum./n", "rc": 0, "results": [ "Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-/n : manager/n/nThis system is not registered with an entitlement server. You can use subscription-manager to register./n/nResolving Dependencies/n--> Running transaction check/n---> Package gcc.x86_64 0:4.8.5-44.el7 will be installed/n--> Finished Dependency Resolution/n/nDependencies Resolved/n/n================================================================================/n Package Arch Version Repository Size/n================================================================================/nInstalling:/n gcc x86_64 4.8.5-44.el7 rhel7 16 M/n/nTransaction Summary/n================================================================================/nInstall 1 Package/n/nTotal download size: 16 M/nInstalled size: 37 M/nDownloading packages:/nRunning transaction check/nRunning transaction test/nTransaction test succeeded/nRunning transaction/n Installing : gcc-4.8.5-44.el7.x86_64 1/1 /n Verifying : gcc-4.8.5-44.el7.x86_64 1/1 /n/nInstalled:/n gcc.x86_64 0:4.8.5-44.el7 /n/nComplete!/n" ]}

3.安装独立的rpm包

[root@ansible ~]# ansible mysql -m yum -a 'name=/home/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm'192.168.56.88 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "changes": { "installed": [ "/home/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm" ] }, "msg": "", "rc": 0, "results": [ "Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-/n : manager/n/nThis system is not registered with an entitlement server. You can use subscription-manager to register./n/nExamining /home/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm: compat-libstdc++-33-3.2.3-72.el7.x86_64/nMarking /home/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm to be installed/nResolving Dependencies/n--> Running transaction check/n---> Package compat-libstdc++-33.x86_64 0:3.2.3-72.el7 will be installed/n--> Finished Dependency Resolution/n/nDependencies Resolved/n/n================================================================================/n Package Arch Version Repository Size/n================================================================================/nInstalling:/n compat-libstdc++-33/n x86_64 3.2.3-72.el7 /compat-libstdc++-33-3.2.3-72.el7.x86_64 811 k/n/nTransaction Summary/n================================================================================/nInstall 1 Package/n/nTotal size: 811 k/nInstalled size: 811 k/nDownloading packages:/nRunning transaction check/nRunning transaction test/nTransaction test succeeded/nRunning transaction/n Installing : compat-libstdc++-33-3.2.3-72.el7.x86_64 1/1 /n Verifying : compat-libstdc++-33-3.2.3-72.el7.x86_64 1/1 /n/nInstalled:/n compat-libstdc++-33.x86_64 0:3.2.3-72.el7 /n/nComplete!/n" ]}[root@ansible ~]# ansible mysql -m yum -a 'name=/home/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm'192.168.56.88 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "msg": "", "rc": 0, "results": [ "compat-libstdc++-33-3.2.3-72.el7.x86_64 providing /home/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm is already installed" ]

4.安装gcc并清除缓存

[root@ansible ~]# ansible mysql -m yum -a 'name=gcc update_cache=yes'192.168.56.88 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "changes": { "installed": [ "gcc" ] }, "msg": "Warning: RPMDB altered outside of yum./n", "rc": 0, "results": [ "Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-/n : manager/n/nThis system is not registered with an entitlement server. You can use subscription-manager to register./n/nResolving Dependencies/n--> Running transaction check/n---> Package gcc.x86_64 0:4.8.5-44.el7 will be installed/n--> Finished Dependency Resolution/n/nDependencies Resolved/n/n================================================================================/n Package Arch Version Repository Size/n================================================================================/nInstalling:/n gcc x86_64 4.8.5-44.el7 rhel7 16 M/n/nTransaction Summary/n================================================================================/nInstall 1 Package/n/nTotal download size: 16 M/nInstalled size: 37 M/nDownloading packages:/nRunning transaction check/nRunning transaction test/nTransaction test succeeded/nRunning transaction/n Installing : gcc-4.8.5-44.el7.x86_64 1/1 /n Verifying : gcc-4.8.5-44.el7.x86_64 1/1 /n/nInstalled:/n gcc.x86_64 0:4.8.5-44.el7 /n/nComplete!/n" ]}

ansible

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序-GetWeApp金盆洗脚城[全栈]
下一篇:WeCOS - 微信小程序 COS 瘦身解决方案
相关文章

 发表评论

暂时没有评论,来抢沙发吧~