From 3aa27f1beb22f950ed10ba46cb7d0f1028b2943c Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Tue, 21 Apr 2020 14:50:16 +0200 Subject: [PATCH] Use test_become flag in Tobiko ansible roles Change-Id: Ic8b6895b0bdab441b6aec0a6c8007252bfaaa5f0 --- roles/tobiko-bindep/meta/main.yaml | 3 ++- roles/tobiko-bindep/tasks/main.yaml | 2 +- roles/tobiko-ensure-git/meta/main.yaml | 4 ++++ roles/tobiko-ensure-git/tasks/git.yaml | 7 +++++-- roles/tobiko-ensure-python3/tasks/install.yaml | 2 +- roles/tobiko-ensure-python3/tasks/python3.yaml | 2 +- roles/tobiko-ensure-rsync/meta/main.yaml | 4 ++++ roles/tobiko-ensure-rsync/tasks/rsync.yaml | 5 ++++- roles/tobiko-inventory/tasks/main.yaml | 4 ++-- 9 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 roles/tobiko-ensure-git/meta/main.yaml create mode 100644 roles/tobiko-ensure-rsync/meta/main.yaml diff --git a/roles/tobiko-bindep/meta/main.yaml b/roles/tobiko-bindep/meta/main.yaml index 97b06fff8..5e9fd72e8 100644 --- a/roles/tobiko-bindep/meta/main.yaml +++ b/roles/tobiko-bindep/meta/main.yaml @@ -1,4 +1,5 @@ --- dependencies: - - role: tobiko-ensure-python3 + - tobiko-common + - tobiko-ensure-python3 diff --git a/roles/tobiko-bindep/tasks/main.yaml b/roles/tobiko-bindep/tasks/main.yaml index 3e057f312..cf6156aac 100644 --- a/roles/tobiko-bindep/tasks/main.yaml +++ b/roles/tobiko-bindep/tasks/main.yaml @@ -27,7 +27,7 @@ failed_when: yes - name: 'install missing packages' - become: yes + become: '{{ test_become | bool }}' package: name: '{{ run_bindep.stdout_lines }}' register: install_packages diff --git a/roles/tobiko-ensure-git/meta/main.yaml b/roles/tobiko-ensure-git/meta/main.yaml new file mode 100644 index 000000000..0d4361583 --- /dev/null +++ b/roles/tobiko-ensure-git/meta/main.yaml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: tobiko-common diff --git a/roles/tobiko-ensure-git/tasks/git.yaml b/roles/tobiko-ensure-git/tasks/git.yaml index b7aa7de74..9311712f9 100644 --- a/roles/tobiko-ensure-git/tasks/git.yaml +++ b/roles/tobiko-ensure-git/tasks/git.yaml @@ -4,17 +4,19 @@ - name: "get '{{ git_executable }}' full path" shell: > which '{{ git_executable }}' + changed_when: no register: get_git_path rescue: - - name: "install Git packages" - become: true + - name: "install Git package" + become: '{{ test_become | bool }}' package: name: git - name: "get '{{ git_executable }}' full path" shell: > which '{{ git_executable }}' + changed_when: no register: get_git_path @@ -26,6 +28,7 @@ - name: "get Git version" command: > '{{ git_executable }}' --version + changed_when: no register: get_git_version diff --git a/roles/tobiko-ensure-python3/tasks/install.yaml b/roles/tobiko-ensure-python3/tasks/install.yaml index f65057407..5e7f11e39 100644 --- a/roles/tobiko-ensure-python3/tasks/install.yaml +++ b/roles/tobiko-ensure-python3/tasks/install.yaml @@ -1,7 +1,7 @@ --- - name: "install '{{ python_command }}' packages" - become: true + become: '{{ test_become | bool }}' package: name: "{{ python_packages[python_command] | flatten }}" when: 'python_command in python_packages' diff --git a/roles/tobiko-ensure-python3/tasks/python3.yaml b/roles/tobiko-ensure-python3/tasks/python3.yaml index 13f6e2dcd..1fcb6dcfc 100644 --- a/roles/tobiko-ensure-python3/tasks/python3.yaml +++ b/roles/tobiko-ensure-python3/tasks/python3.yaml @@ -34,7 +34,7 @@ rescue: - name: "try setting python alternative to '{{ python_alternative }}'" - become: true + become: '{{ test_become | bool }}' command: "alternatives --set python '{{ python_alternative }}'" ignore_errors: yes when: 'python_alternative is defined' diff --git a/roles/tobiko-ensure-rsync/meta/main.yaml b/roles/tobiko-ensure-rsync/meta/main.yaml new file mode 100644 index 000000000..0d4361583 --- /dev/null +++ b/roles/tobiko-ensure-rsync/meta/main.yaml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: tobiko-common diff --git a/roles/tobiko-ensure-rsync/tasks/rsync.yaml b/roles/tobiko-ensure-rsync/tasks/rsync.yaml index bf1fb3bcf..f67cfef6a 100644 --- a/roles/tobiko-ensure-rsync/tasks/rsync.yaml +++ b/roles/tobiko-ensure-rsync/tasks/rsync.yaml @@ -4,17 +4,19 @@ - name: "get '{{ rsync_executable }}' full path" shell: > which '{{ rsync_executable }}' + changed_when: no register: get_rsync_path rescue: - name: "install Rsync packages" - become: true + become: '{{ test_become | bool }}' package: name: rsync - name: "get '{{ rsync_executable }}' full path" shell: > which '{{ rsync_executable }}' + changed_when: no register: get_rsync_path @@ -26,6 +28,7 @@ - name: "get Rsync version" command: > '{{ rsync_executable }}' --version + changed_when: no register: get_rsync_version diff --git a/roles/tobiko-inventory/tasks/main.yaml b/roles/tobiko-inventory/tasks/main.yaml index 116fc7921..749b3a452 100644 --- a/roles/tobiko-inventory/tasks/main.yaml +++ b/roles/tobiko-inventory/tasks/main.yaml @@ -17,8 +17,8 @@ block: - name: "get remote username" command: whoami - changed_when: false - become: false + changed_when: no + become: no register: get_inventory_user - name: "set test_inventory_user fact"