Ansible 安裝多個 package

安裝一個package

- name: install epel
  yum:
    name: epel-release
    state: latest
    update_cache: yes

安裝多個package

不能在name的部分用空格給多個package名稱

該怎麼辦呢?

可以用變數搭配List

- name: install tools
  yum:
    name: "{{ item }}"
    state: latest
    update_cache: yes
  with_items:
    - git
    - wget
    - gcc
    - gcc-c++
    - pcre-devel
    - zlib-devel 
    - openssl 
    - openssl-devel 
    - httpd-devel 
    - libxml2-devel 
    - xz-devel 
    - python-devel 
    - libcurl-devel 
    - libxslt-devel 
    - gd 
    - gd-devel 
    - gmp 
    - gmp-devel 
    - perl-Tk-devel 
    - perl-ExtUtils-Embed.noarch 
    - GeoIP 
    - GeoIP-devel 
    - gperftools 
    - gperftools-devel