/
ansible yum module 사용법

ansible yum module 사용법

ansible 은 패키지 설치를 위해 yum 모듈을 제공하고 있으므로 패키지를 쉽게 설치할 수 있습니다.


다음과 같이 설치할 패키지 이름을 name 필드에 기술하면 되며 여러 개일 경우 배열로 작성해 주면 됩니다.

- name: Install a list of packages
  yum:
    name:
      - nginx
      - mariadb-server
    state: present


만약 remi 저장소 설치 파일처럼 rpm 이 remote 에 있을 경우 name 필드에 리모트의 URL 을 적어주면 됩니다.


다음은 ansible_distribution_major_version 팩트 변수를 사용해서 OS 에 맞는 remi 저장소 파일을 설치하는 예제입니다.

---
## install various PHP version on the RHEL/CentOS 7/8

- name: install PHP
  hosts: web
  gather_facts: yes
  vars:
    remi_url: "http://rpms.remirepo.net/enterprise/remi-release-{{ ansible_distribution_major_version }}.rpm"
  become: true
  become_method: sudo
  tasks:
      - name: install remi release
        yum:
            name: "{{ remi_url }}"


Ref

Related content

앤서블(ansible) 설치
앤서블(ansible) 설치
More like this
ansible ad-hoc(앤서블 애드혹) 명령어 사용법
ansible ad-hoc(앤서블 애드혹) 명령어 사용법
More like this
ansible 4로 업그레이드 하기
ansible 4로 업그레이드 하기
More like this
yumdownloader 명령어로 yum 패키지를 설치하지 않고 download 만 하기
yumdownloader 명령어로 yum 패키지를 설치하지 않고 download 만 하기
More like this
ansible setup 모듈로 facts 수집하기
ansible setup 모듈로 facts 수집하기
More like this
yum 주요 사용법 및 고급 사용법 (history 관리, plugin 사용, 트랜잭션 undo 등)
yum 주요 사용법 및 고급 사용법 (history 관리, plugin 사용, 트랜잭션 undo 등)
More like this