[2.10] Docsite backport of 72049, 72052, 72053 (#72071)

* Docsite: update user_guide/playbooks_prompts (#72049)

(cherry picked from commit 3efc8b6de8)

* Docsite: update user_guide/playbooks_checkmode (#72052)

(cherry picked from commit c12fce3aa9)

* Docsite: update user_guide/playbooks_debugger (#72053)

(cherry picked from commit 77840f886e)
This commit is contained in:
Andrew Klychkov 2020-10-09 18:53:47 +03:00 committed by GitHub
parent c24bdfa7df
commit f9ecb4fe74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 30 deletions

View file

@ -31,15 +31,15 @@ If you want certain tasks to run in check mode always, or never, regardless of w
For example::
tasks:
- name: this task will always make changes to the system
command: /something/to/run --even-in-check-mode
- name: This task will always make changes to the system
ansible.builtin.command: /something/to/run --even-in-check-mode
check_mode: no
- name: this task will never make changes to the system
lineinfile:
line: "important config"
dest: /path/to/myconfig.conf
state: present
- name: This task will never make changes to the system
ansible.builtin.lineinfile:
line: "important config"
dest: /path/to/myconfig.conf
state: present
check_mode: yes
register: changes_to_important_config
@ -56,14 +56,14 @@ If you want to skip a task or ignore errors on a task when you run Ansible in ch
tasks:
- name: this task will be skipped in check mode
git:
- name: This task will be skipped in check mode
ansible.builtin.git:
repo: ssh://git@github.com/mylogin/hello.git
dest: /home/mylogin/hello
when: not ansible_check_mode
- name: this task will ignore errors in check mode
git:
- name: This task will ignore errors in check mode
ansible.builtin.git:
repo: ssh://git@github.com/mylogin/hello.git
dest: /home/mylogin/hello
ignore_errors: "{{ ansible_check_mode }}"
@ -87,8 +87,8 @@ Enforcing or preventing diff mode on tasks
Because the ``--diff`` option can reveal sensitive information, you can disable it for a task by specifying ``diff: no``. For example::
tasks:
- name: this task will not report a diff when the file changes
template:
- name: This task will not report a diff when the file changes
ansible.builtin.template:
src: secret.conf.j2
dest: /etc/secret.conf
owner: root

View file

@ -55,7 +55,7 @@ Example of setting the ``debugger`` keyword on a task:
.. code-block:: yaml
- name: Execute a command
command: "false"
ansible.builtin.command: "false"
debugger: on_failed
Example of setting the ``debugger`` keyword on a play:
@ -67,7 +67,7 @@ Example of setting the ``debugger`` keyword on a play:
debugger: on_skipped
tasks:
- name: Execute a command
command: "true"
ansible.builtin.command: "true"
when: False
Example of setting the ``debugger`` keyword at multiple levels:
@ -80,7 +80,7 @@ Example of setting the ``debugger`` keyword at multiple levels:
debugger: never
tasks:
- name: Execute a command
command: "false"
ansible.builtin.command: "false"
debugger: on_failed
In this example, the debugger is set to ``never`` at the play level and to ``on_failed`` at the task level. If the task fails, Ansible invokes the debugger, because the definition on the task overrides the definition on its parent play.
@ -137,8 +137,8 @@ After Ansible invokes the debugger, you can use the seven :ref:`debugger command
vars:
var1: value1
tasks:
- name: wrong variable
ping: data={{ wrong_var }}
- name: Use a wrong variable
ansible.builtin.ping: data={{ wrong_var }}
If you run this playbook, Ansible invokes the debugger when the task fails. From the debug prompt, you can change the module arguments or the variables and run the task again.
@ -248,8 +248,8 @@ Update args command
vars:
pkg_name: not_exist
tasks:
- name: install package
apt: name={{ pkg_name }}
- name: Install a package
ansible.builtin.apt: name={{ pkg_name }}
When you run the playbook, the invalid package name triggers an error, and Ansible invokes the debugger. You can fix the package name by viewing, then updating the module argument::

View file

@ -16,15 +16,16 @@ Here is a most basic example::
vars_prompt:
- name: username
prompt: "What is your username?"
prompt: What is your username?
private: no
- name: password
prompt: "What is your password?"
prompt: What is your password?
tasks:
- debug:
- name: Print a message
ansible.builtin.debug:
msg: 'Logging in as {{ username }}'
The user input is hidden by default but it can be made visible by setting ``private: no``.
@ -36,8 +37,8 @@ If you have a variable that changes infrequently, you can provide a default valu
vars_prompt:
- name: "release_version"
prompt: "Product release version"
- name: release_version
prompt: Product release version
default: "1.0"
Encrypting values supplied by ``vars_prompt``
@ -47,10 +48,10 @@ You can encrypt the entered value so you can use it, for instance, with the user
vars_prompt:
- name: "my_password2"
prompt: "Enter password2"
- name: my_password2
prompt: Enter password2
private: yes
encrypt: "sha512_crypt"
encrypt: sha512_crypt
confirm: yes
salt_size: 7
@ -96,8 +97,8 @@ Allowing special characters in ``vars_prompt`` values
Some special characters, such as ``{`` and ``%`` can create templating errors. If you need to accept special characters, use the ``unsafe`` option::
vars_prompt:
- name: "my_password_with_weird_chars"
prompt: "Enter password"
- name: my_password_with_weird_chars
prompt: Enter password
unsafe: yes
private: yes