AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
用途: 包管理器,通过包管理器安装软件 [admin@node1 tasks]$ ansible-doc -s package - name: Generic OS package manager package: name: # (required) Package name, or package specifier with version, like `name-1.0'. Be aware that packages are not always named the same and this module will not 'translate' them per distro. state: # (required) Whether to install (`present', or remove (`absent') a package. Other states depend on the underlying package module, i.e `latest'. use: # The required package manager module to use (yum, apt, etc). The default 'auto' will use existing facts or try to autodetect it. You should only use this field if the automatic selection is not working for some reason. 常用选项: name 指定要安装的软件包名 state: present 安装 absent 卸载 案例1: ~~~ [admin@node1 ~]$ ansible webserver -m package -a "name=openssl-devel state=present" -b --ask-sudo-pass [DEPRECATION WARNING]: The sudo command line option has been deprecated in favor of the "become" command line arguments. This feature will be removed in version 2.6. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. SUDO password: 192.168.20.138 | SUCCESS => { "changed": false, "msg": "", "rc": 0, "results": [ "1:openssl-devel-1.0.2k-8.el7.x86_64 providing openssl-devel is already installed" ] } 192.168.20.137 | SUCCESS => { "changed": false, "msg": "", "rc": 0, "results": [ "1:openssl-devel-1.0.2k-8.el7.x86_64 providing openssl-devel is already installed" ] } ~~~ 案例2: ~~~ - name: install_from_source | Ensure dependencies for building from source are installed. package: "name={{ item }} state=installed" with_items: "{{ php_packages }}" ~~~