diff options
author | Brenton Leanhardt <bleanhar@redhat.com> | 2015-12-09 16:44:55 -0500 |
---|---|---|
committer | Brenton Leanhardt <bleanhar@redhat.com> | 2015-12-09 16:44:55 -0500 |
commit | ec7b8b68b6467e17487ec4c81fbe2c6826e3c889 (patch) | |
tree | cba54e9138630742d0788a5cff9f70ec75b93032 /docs/best_practices_guide.adoc | |
parent | ecae1fcaaf6d83f2fb6dce0624990b2d13c25db9 (diff) | |
parent | b1d30491f1581503003646684137bf2c218660ba (diff) | |
download | openshift-ec7b8b68b6467e17487ec4c81fbe2c6826e3c889.tar.gz openshift-ec7b8b68b6467e17487ec4c81fbe2c6826e3c889.tar.bz2 openshift-ec7b8b68b6467e17487ec4c81fbe2c6826e3c889.tar.xz openshift-ec7b8b68b6467e17487ec4c81fbe2c6826e3c889.zip |
Merge pull request #1046 from sdodson/yum-dnf-cleanup
Remove yum / dnf duplication
Diffstat (limited to 'docs/best_practices_guide.adoc')
-rw-r--r-- | docs/best_practices_guide.adoc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/best_practices_guide.adoc b/docs/best_practices_guide.adoc index 08d95b2b8..6b744333c 100644 --- a/docs/best_practices_guide.adoc +++ b/docs/best_practices_guide.adoc @@ -466,3 +466,50 @@ If you want to use default with variables that evaluate to false you have to set In other words, normally the `default` filter will only replace the value if it's undefined. By setting the second parameter to `true`, it will also replace the value if it defaults to a false value in python, so None, empty list, empty string, etc. This is almost always more desirable than an empty list, string, etc. + +=== Yum and DNF +''' +[cols="2v,v"] +|=== +| **Rule** +| Package installation MUST use ansible action module to abstract away dnf/yum. +| Package installation MUST use name= and state=present rather than pkg= and state=installed respectively. +|=== +[cols="2v,v"] +|=== +| **Rule** +| Package installation MUST use name= and state=present rather than pkg= and state=installed respectively. +|=== + +This is done primarily because if you're registering the result of the +installation and you have two conditional tasks based on whether or not yum or +dnf are in use you'll end up inadvertently overwriting the value. It also +reduces duplication. name= and state=present are common between dnf and yum +modules. + +.Bad: +[source,yaml] +---- +--- +# tasks.yml +- name: Install etcd (for etcdctl) + yum: name=etcd state=latest" + when: "ansible_pkg_mgr == yum" + register: install_result + +- name: Install etcd (for etcdctl) + dnf: name=etcd state=latest" + when: "ansible_pkg_mgr == dnf" + register: install_result +---- + + +.Good: +[source,yaml] +---- +--- +# tasks.yml +- name: Install etcd (for etcdctl) + action: "{{ ansible_pkg_mgr }} name=etcd state=latest" + register: install_result + ---- |