사용자 도구

사이트 도구


build_deploy_management:ansible

문서의 이전 판입니다!


Ansible

AWS

become

  • become: yes 일 경우 sudo 로 명령을 실행한다.
  • 이때, 비밀번호를 받는 다양한 방법이 존재할 수 있는데, 일단 ansible-playbook--ask-become-pass 옵션을 주면 최초 시작시 비밀번호를 물어본다.

Local 실행

- name: playbook name
  hosts: 127.0.0.1
  connection: local
  tasks:
    - name: blah.. blah..
# 실행
ansible-playbook playbook.yml

File 생성

  tasks:
  - name: Ansible create file with content example
    copy:
      dest: "/Users/mdtutorials2/Documents/Ansible/remote_server.txt"
      content: "contents"
      mode: 0777
      owner: mdtutorials2

환경변수 읽기

- debug: msg="{{ lookup('env', 'HOME') }} is an environment variable"

변수(var) 외부에 두고 include

- name: blah blah..
  hosts: ...
  vars_files:
    - "vars.yml" # file in the same directory
  tasks: ...
  • vars.yml
# key/value 쌍.
ubuntu_release: "{{ lookup('pipe', 'lsb_release -cs') }}"
current_user: "{{ lookup('env', 'USER') }}"
vagrant_version: 2.2.10
packer_version: 1.6.1
...

shell & command

apt repository

참조

build_deploy_management/ansible.1600009494.txt.gz · 마지막으로 수정됨: 2020/09/14 00:04 저자 kwon37xi