summaryrefslogtreecommitdiffstats
path: root/docs/best_practices_guide.adoc
diff options
context:
space:
mode:
authorThomas Wiest <twiest@redhat.com>2015-06-03 15:25:16 -0400
committerThomas Wiest <twiest@redhat.com>2015-06-03 15:55:13 -0400
commit52f61e9f738de8e53b09e0237a23514a4249e370 (patch)
treed7431b47ad8be5bfe89a2578d4d4d31813bd0f75 /docs/best_practices_guide.adoc
parent433e3c77adf99cfaa5d6b8f94d2f0065f187b0fc (diff)
downloadopenshift-52f61e9f738de8e53b09e0237a23514a4249e370.tar.gz
openshift-52f61e9f738de8e53b09e0237a23514a4249e370.tar.bz2
openshift-52f61e9f738de8e53b09e0237a23514a4249e370.tar.xz
openshift-52f61e9f738de8e53b09e0237a23514a4249e370.zip
Added fail pattern rules to best practices doc
Diffstat (limited to 'docs/best_practices_guide.adoc')
-rw-r--r--docs/best_practices_guide.adoc46
1 files changed, 44 insertions, 2 deletions
diff --git a/docs/best_practices_guide.adoc b/docs/best_practices_guide.adoc
index 301c6ccda..14bd0bb53 100644
--- a/docs/best_practices_guide.adoc
+++ b/docs/best_practices_guide.adoc
@@ -19,7 +19,6 @@ This guide complies with https://www.ietf.org/rfc/rfc2119.txt[RFC2119].
| All pull requests MUST pass the build bot *before* they are merged.
|===
-
The purpose of this rule is to avoid cases where the build bot will fail pull requests for code modified in a previous pull request.
The tooling is flexible enough that exceptions can be made so that the tool the build bot is running will ignore certain areas or certain checks, but the build bot itself must pass for the pull request to be merged.
@@ -78,6 +77,49 @@ metadata[line] = results.pop()
== Ansible
+=== Defensive Programming
+
+.Context
+* http://docs.ansible.com/fail_module.html[Ansible Fail Module]
+
+'''
+[cols="2v,v"]
+|===
+| **Rule**
+| Ansible playbooks MUST begin with checks for any variables that they require.
+|===
+
+If an Ansible playbook requires certain variables to be set, it's best to check for these up front before any other actions have been performed. In this way, the user knows exactly what needs to be passed into the playbook.
+
+.Example:
+[source,yaml]
+----
+---
+- hosts: localhost
+ gather_facts: no
+ tasks:
+ - fail: msg="This playbook requires g_environment to be set and non empty"
+ when: g_environment is not defined or g_environment == ''
+----
+
+'''
+[cols="2v,v"]
+|===
+| **Rule**
+| Ansible roles tasks/main.yml file MUST begin with checks for any variables that they require.
+|===
+
+If an Ansible role requires certain variables to be set, it's best to check for these up front before any other actions have been performed. In this way, the user knows exactly what needs to be passed into the role.
+
+.Example:
+[source,yaml]
+----
+---
+# tasks/main.yml
+- fail: msg="This role requires arl_environment to be set and non empty"
+ when: arl_environment is not defined or arl_environment == ''
+----
+
=== Roles
.Context
* http://docs.ansible.com/playbooks_best_practices.html#directory-layout[Ansible Suggested Directory Layout]
@@ -101,7 +143,7 @@ metadata[line] = results.pop()
| Ansible Roles SHOULD be named like technology_component[_subcomponent].
|===
-For clarity, it is suggested to follow a pattern when naming roles. It is important to note that this is a recommendation for role naming, and follows the pattern used by upstream.
+For consistency, role names SHOULD follow the above naming pattern. It is important to note that this is a recommendation for role naming, and follows the pattern used by upstream.
Many times the `technology` portion of the pattern will line up with a package name. It is advised that whenever possible, the package name should be used.