aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Arbet <michal.arbet@ultimum.io>2021-08-19 14:57:31 +0200
committerMichal Arbet <michal.arbet@ultimum.io>2021-09-21 17:08:39 +0200
commit0e720b382b7914ff3cce715f2608bd92cad41a2d (patch)
treefa2e1dbaf602c62ccd9027d11bf87c211073bae4
parent98479f5e28faceab7ba108d034e2270e129e9bd2 (diff)
downloadkolla-ansible-0e720b382b7914ff3cce715f2608bd92cad41a2d.tar.gz
kolla-ansible-0e720b382b7914ff3cce715f2608bd92cad41a2d.zip
Add check and diff options to kolla-ansible
This patch is adding --check and --diff options to kolla-ansible, which cause that kolla-ansible run will be more verbose and able to run in semi dry-run mode. The --diff option for kolla-ansible can be used alone or with --check. When you run in diff mode, any module that supports diff mode reports the changes made or, if used with --check, the changes that would have been made. Diff mode is most common in modules that manipulate files (for example, the template module) but other modules might also show ‘before and after’ information (for example, the user module). For more information check [1]. [1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html#using-diff-mode Change-Id: Ifb82ea99e5af82540e938eab9e2a442b2820d7df
-rw-r--r--releasenotes/notes/kolla-ansible-diff-50de16722aa155dc.yaml5
-rwxr-xr-xtools/kolla-ansible18
2 files changed, 21 insertions, 2 deletions
diff --git a/releasenotes/notes/kolla-ansible-diff-50de16722aa155dc.yaml b/releasenotes/notes/kolla-ansible-diff-50de16722aa155dc.yaml
new file mode 100644
index 000000000..f3d95c28b
--- /dev/null
+++ b/releasenotes/notes/kolla-ansible-diff-50de16722aa155dc.yaml
@@ -0,0 +1,5 @@
+---
+features:
+ - |
+ Adds two new arguments to the ``kolla-ansible`` command, ``--check``
+ and ``--diff``. They are passed through directly to ``ansible-playbook``.
diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index a6d222b7a..0b4a0897f 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -140,6 +140,8 @@ Can be specified multiple times to pass multiple inventories.
--vault-id <@prompt or path> Specify @prompt or password file (Ansible >= 2.4)
--ask-vault-pass Ask for vault password
--vault-password-file <path> Specify password file for vault decrypt
+ --check, -C Don't make any changes and try to predict some of the changes that may occur instead
+ --diff, -D Show differences in ansible-playbook changed tasks
--verbose, -v Increase verbosity of ansible-playbook
Environment variables:
@@ -191,6 +193,8 @@ cat <<EOF
--vault-id
--ask-vault-pass
--vault-password-file
+--check -C
+--diff -D
--verbose -v
prechecks
check
@@ -218,8 +222,8 @@ EOF
check_environment_coherence
-SHORT_OPTS="hi:p:t:k:e:v"
-LONG_OPTS="help,inventory:,playbook:,skip-tags:,tags:,key:,extra:,verbose,configdir:,passwords:,limit:,forks:,vault-id:,ask-vault-pass,vault-password-file:,yes-i-really-really-mean-it,include-images,include-dev:,full,incremental"
+SHORT_OPTS="hi:p:t:k:e:CD:v"
+LONG_OPTS="help,inventory:,playbook:,skip-tags:,tags:,key:,extra:,check,diff,verbose,configdir:,passwords:,limit:,forks:,vault-id:,ask-vault-pass,vault-password-file:,yes-i-really-really-mean-it,include-images,include-dev:,full,incremental"
RAW_ARGS="$*"
ARGS=$(getopt -o "${SHORT_OPTS}" -l "${LONG_OPTS}" --name "$0" -- "$@") || { usage >&2; exit 2; }
@@ -265,6 +269,16 @@ while [ "$#" -gt 0 ]; do
shift 2
;;
+ (--check|-C)
+ EXTRA_OPTS="$EXTRA_OPTS --check"
+ shift 1
+ ;;
+
+ (--diff|-D)
+ EXTRA_OPTS="$EXTRA_OPTS --diff"
+ shift 1
+ ;;
+
(--verbose|-v)
VERBOSITY="$VERBOSITY --verbose"
shift 1