Ansible Module - Package

Create a playbook httpd.yml under ~/playbooks/ to install httpd package on web1 node using Ansible’s yum module.

---
- name: install httpd
  hosts: web1
  tasks:
  - yum:
      name: httpd
      state: installed

I have an rpm available for wget package on URL http://mirror.centos.org/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm. Create a playbook with name wget.yml under ~/playbooks to install that rpm on web1 node using yum module.

---
- name: wget package
  hosts: web1
  tasks:
  - yum:
      name: http://mirror.centos.org/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm
      state: present  ; present == installed  

최신 버전 업데이트

- hosts: all
  tasks:
    - name: Install iotop package
      yum:
        name: iotop
        state: latest  ; 설치되어 있어도 최신버전이 아니면 패키지를 업데이트 한다

다운 그레이드 (vsftpd-3.0.2 → vsftpd-2.2.2)

- name: more packages
  hosts: web1
  tasks: 
  - yum:
      name: sudo
      state: latest

  - yum:
      name: vsftpd-2.2.2
      state: installed
      allow_downgrade: yes

좋은 웹페이지 즐겨찾기