Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Commit

Permalink
Add "Positioning and use of the become directive"
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt committed Apr 19, 2022
1 parent d7cf561 commit 0ee3218
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion source/development/ansible-style-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,29 @@
Ansible Style Guide
===================

We implement all the default rules of Ansible Lint. A listing of all these rules can be found in the Ansible Lint documentation: https://ansible-lint.readthedocs.io/en/latest/default_rules/
We implement all the default rules of Ansible Lint. A listing of all these rules
can be found in the Ansible Lint documentation: https://ansible-lint.readthedocs.io/en/latest/default_rules/

Positioning and use of the become directive
===========================================

The become directive is only set when needed and is always set explicitly
for each task that needs it.

Blocks, roles, or playbooks are never executed in a privileged mode.

We always insert the become directive between the name of a task
and the task itself. This also applies to related directives like become_user
or become_flags. This is for better visibility if a task is privileged or not.

.. code-block:: yaml
- name: Copy hddtemp configuration file
become: true
ansible.builtin.copy:
src: "{{ ansible_os_family }}/hddtemp"
dest: "{{ hddtemp_conf_file }}"
owner: root
group: root
mode: 0644
notify: Restart hddtemp service

0 comments on commit 0ee3218

Please sign in to comment.