LoginSignup
0
0

More than 5 years have passed since last update.

ansible オプションメモ

Last updated at Posted at 2016-09-18

ansible-playbook のオプション

sudo のパスワードを確認

ansible-playbook --ask-become-pass main.yml
ansible-playbook --ask-sudo-pass main.yml #when using sudo instead of become

playbook で使う

Hosts and Users

hostsでホストやグループを指定、remote_userでリモートユーザを指定.
指定にはパターンが使える.

---
- hosts: webservers
  remote_user: root

remote_user はversion 1.4 からtask でも指定できる.

taskで使う

register

モジュールの出力を変数に格納する

- name: hogehoge
  yum: name=vim state=latest
  register: ret

failed_when

ansible では終了ステータスが0以外のものをエラーとして解釈する.
failed_when はこれを変更し、エラーとなる条件式をユーザが指定できるようにする.

- name: hogehoge
  yum: name=emacs state=latest
  register: ret
  failed_when: ret not in [0, 1]

ignore_errors

エラーが起きても停止しない

- shell: cat /
  ignore_errors: True

Ref

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0