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

View file

@ -55,7 +55,7 @@ Example of setting the ``debugger`` keyword on a task:
.. code-block:: yaml .. code-block:: yaml
- name: Execute a command - name: Execute a command
command: "false" ansible.builtin.command: "false"
debugger: on_failed debugger: on_failed
Example of setting the ``debugger`` keyword on a play: 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 debugger: on_skipped
tasks: tasks:
- name: Execute a command - name: Execute a command
command: "true" ansible.builtin.command: "true"
when: False when: False
Example of setting the ``debugger`` keyword at multiple levels: Example of setting the ``debugger`` keyword at multiple levels:
@ -80,7 +80,7 @@ Example of setting the ``debugger`` keyword at multiple levels:
debugger: never debugger: never
tasks: tasks:
- name: Execute a command - name: Execute a command
command: "false" ansible.builtin.command: "false"
debugger: on_failed 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. 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: vars:
var1: value1 var1: value1
tasks: tasks:
- name: wrong variable - name: Use a wrong variable
ping: data={{ wrong_var }} 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. 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: vars:
pkg_name: not_exist pkg_name: not_exist
tasks: tasks:
- name: install package - name: Install a package
apt: name={{ pkg_name }} 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:: 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: vars_prompt:
- name: username - name: username
prompt: "What is your username?" prompt: What is your username?
private: no private: no
- name: password - name: password
prompt: "What is your password?" prompt: What is your password?
tasks: tasks:
- debug: - name: Print a message
ansible.builtin.debug:
msg: 'Logging in as {{ username }}' msg: 'Logging in as {{ username }}'
The user input is hidden by default but it can be made visible by setting ``private: no``. 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: vars_prompt:
- name: "release_version" - name: release_version
prompt: "Product release version" prompt: Product release version
default: "1.0" default: "1.0"
Encrypting values supplied by ``vars_prompt`` 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: vars_prompt:
- name: "my_password2" - name: my_password2
prompt: "Enter password2" prompt: Enter password2
private: yes private: yes
encrypt: "sha512_crypt" encrypt: sha512_crypt
confirm: yes confirm: yes
salt_size: 7 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:: Some special characters, such as ``{`` and ``%`` can create templating errors. If you need to accept special characters, use the ``unsafe`` option::
vars_prompt: vars_prompt:
- name: "my_password_with_weird_chars" - name: my_password_with_weird_chars
prompt: "Enter password" prompt: Enter password
unsafe: yes unsafe: yes
private: yes private: yes