Ansible18 Ansible Variables 앤서블은 플레이북에서 재활용할 수 있도록 변수(variable)를 지원한다. 변수는 다음과 같이 반복적이거나 동적인 값을 관리할 때 편리하다. 여러 사용자를 생성 여러 패키지를 설치 여러 서비스를 재시작 변수 정의하기 플레이북 안에 변수를 정의할 경우 시작 위치에 있는 vars 블록에 변수를 정의한다. 인벤토리에서는 각각의 host 명을 정의하기도 한다 {{ }} 안에 변수명을 입력하여 host ip를 대체할 수 있다. playbook1.yaml - name: 'Update nameserver entry into resolv.conf file on localhost' hosts: localhost tasks: - name: 'Update nameserver entry into resolv.conf fil.. 2023. 6. 27. 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 We 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 tha.. 2023. 6. 27. Ansible Module - Setup ansible facts 란 ansible facts 는 remote host 에 대한 정보를 의미하며 배포판 종류, 버전, IP Address, file system 정보등을 포함. ansible 은 playbook 실행시 자동으로 fact 를 수집하고 저장한다. playbook을 작성하지 않고 간단하게 fact 만 출력하려면 builtin 모듈인 setup 을 사용한다. ansible -m setup localhost ansible -m setup localhost | grep distribution inventory 파일을 사용 ansible -i inventory -m setup web1 | grep distribution playbook - hosts: db1 gather_facts: true .. 2023. 6. 27. Ansible Module - File https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html#file-module ansible.builtin.file module – Manage files and file properties — Ansible Documentation The permissions the resulting filesystem object should have. For those used to /usr/bin/chmod remember that modes are actually octal numbers. You must give Ansible enough information to parse them correctly. For co.. 2023. 6. 27. 이전 1 2 3 4 5 다음