1 병렬구성
1) ansible.cfg
forks = 5
2) ansible-playbook --forks 5
2. Serial 구성
1) ansible-playbook --serial 2
2) task 설정
name
hosts:
serial: 2
3. 비동기 작업
작업을 기다려야 한다면, async, poll 키워드를 사용하여
- name: long tasks
hosts: test1
remote_user: devops
tasks:
- name : download
get_url : url=http://.../test.tar.gz
async: 3600
poll: 10
- name: restart and wait unil the server is rebooted
hosts: test1
remote_user: devops
tasks:
- name : restart machine
shell : sleep 2 && shutdown -r now
async: 1
poll: 0 (대기하지 않음)
become: true
ignore_errors: true
- name: waiting for server to come back
local_action:
wait_for:
host: "{{ inventory_hostname }}"
state: started
delay: 30
timeout: 300
become: false
- name:
hosts: test1
remote_user : devops
become : true
tasks:
- name : download big
get_url: url=http://~~~/test.tar.gz
async: 3600
poll: 0
register: download
- name : wait to finish
async_status: "jid={{ donwload.ansible_job_id }}"
register: job_result
until: job_result.finished
retries: 30
'Devops' 카테고리의 다른 글
ansible vault (0) | 2018.02.12 |
---|---|
ansible role 정의 (0) | 2018.02.12 |
ansible jinja2 템플릿 (0) | 2018.02.12 |
ansible 핸들러 (0) | 2018.02.12 |
ansible 조건 예제 (0) | 2018.02.12 |