功能:软件安装、升级和卸载

常用参数:

name:   待装软件名,必须参数 
state:  present:安装, latest:安装最新, absent:卸载
update_cache:  强制更新yum的缓存 
conf_file:     指定远程yum安装时所依赖的配置文件(安装本地已有的包)。
disable_pgp_check: 是否禁止GPG checking,只用于present latest,默认no
disablerepo:  临时禁止使用yum库 
enablerepo:   临时使用的yum库
举个栗子:
---
- hosts: node
  gather_facts: no
  become: yes
  become_method: sudo

  tasks:
    - name: '安装多个软件'
      yum:
        name: "{{ item }}"
        state: present
      loop:  # 新写法,好用
        - php
        - nginx

    - name: '安装一个,带版本'
      yum:
        name: java-1.8.0-openjdk.x86_64
        state: present

    - name: '移除软件'
      yum:
        name: mariadb*
        state: absent

其他的可参考:

https://blog.csdn.net/qigemingzhendnan/article/details/107456082
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐