Playbook パッケージのインストールの書き方のサンプル

環境
Ansible 2.9
RHEL8
Python 3.8

構文
yum:
name:パッケージ名
state:present

操作例
パッケージhttpdをインストールする

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
- hosts: all
become: yes
tasks:
- name: Install httpd
yum:
name: httpd
state: present
- hosts: all become: yes tasks: - name: Install httpd yum: name: httpd state: present
- hosts: all
  become: yes
  tasks:
    - name: Install httpd
      yum:
        name: httpd
        state: present

Ansible 実行後のインストール済みパッケージ確認
# yum list installed | grep squid

Ansible

Posted by arkgame