Help us understand the problem. What is going on with this article?

ansible オプションメモ

More than 3 years have passed since last update.

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした