From 0300294f6ef2097caabb1ac130d5edd5fa7562b6 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Sat, 22 Aug 2015 19:12:49 -0400 Subject: [PATCH 1/2] Add tests for creates parameter to win_msi module. --- .../roles/test_win_msi/tasks/main.yml | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/test/integration/roles/test_win_msi/tasks/main.yml b/test/integration/roles/test_win_msi/tasks/main.yml index 85c9957a1d..aa5363159a 100644 --- a/test/integration/roles/test_win_msi/tasks/main.yml +++ b/test/integration/roles/test_win_msi/tasks/main.yml @@ -17,21 +17,44 @@ # along with Ansible. If not, see . - name: use win_get_url module to download msi - win_get_url: url=http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.22/7z922-x64.msi dest='C:\\7z922-x64.msi' + win_get_url: + url: http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.22/7z922-x64.msi + dest: "C:\\Program Files\\7z922-x64.msi" register: win_get_url_result +- name: make sure 7-zip is uninstalled + win_msi: + path: "{{ win_get_url_result.win_get_url.dest }}" + state: absent + ignore_errors: true + - name: install 7zip msi - win_msi: path="{{ win_get_url_result.win_get_url.dest }}" + win_msi: + path: "{{ win_get_url_result.win_get_url.dest }}" register: win_msi_install_result - name: check win_msi install result - assert: + assert: that: - "not win_msi_install_result|failed" - "win_msi_install_result|changed" +- name: install 7zip msi again with creates argument + win_msi: + path: "{{ win_get_url_result.win_get_url.dest }}" + creates: "C:\\Program Files\\7-Zip" + register: win_msi_install_again_result + +- name: check win_msi install again result + assert: + that: + - "not win_msi_install_again_result|failed" + - "not win_msi_install_again_result|changed" + - name: uninstall 7zip msi - win_msi: path="{{ win_get_url_result.win_get_url.dest }}" state=absent + win_msi: + path: "{{ win_get_url_result.win_get_url.dest }}" + state: absent register: win_msi_uninstall_result - name: check win_msi uninstall result From 904b8ca27b9d0d4866c59daad865ee36611119ec Mon Sep 17 00:00:00 2001 From: Chris Church Date: Tue, 15 Sep 2015 01:13:30 -0400 Subject: [PATCH 2/2] Update win_msi tests to specify msi url and paths via variables. --- .../roles/test_win_msi/defaults/main.yml | 6 +++++ .../roles/test_win_msi/tasks/main.yml | 22 +++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 test/integration/roles/test_win_msi/defaults/main.yml diff --git a/test/integration/roles/test_win_msi/defaults/main.yml b/test/integration/roles/test_win_msi/defaults/main.yml new file mode 100644 index 0000000000..6e79dcd146 --- /dev/null +++ b/test/integration/roles/test_win_msi/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +msi_url: http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.22/7z922-x64.msi +msi_download_path: "C:\\Program Files\\7z922-x64.msi" +msi_install_path: "C:\\Program Files\\7-Zip" +msi_product_code: "{23170F69-40C1-2702-0922-000001000000}" diff --git a/test/integration/roles/test_win_msi/tasks/main.yml b/test/integration/roles/test_win_msi/tasks/main.yml index aa5363159a..1ac467212a 100644 --- a/test/integration/roles/test_win_msi/tasks/main.yml +++ b/test/integration/roles/test_win_msi/tasks/main.yml @@ -18,19 +18,19 @@ - name: use win_get_url module to download msi win_get_url: - url: http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.22/7z922-x64.msi - dest: "C:\\Program Files\\7z922-x64.msi" + url: "{{msi_url}}" + dest: "{{msi_download_path}}" register: win_get_url_result -- name: make sure 7-zip is uninstalled +- name: make sure msi is uninstalled win_msi: - path: "{{ win_get_url_result.win_get_url.dest }}" + path: "{{msi_product_code|default(msi_download_path,true)}}" state: absent ignore_errors: true -- name: install 7zip msi +- name: install msi win_msi: - path: "{{ win_get_url_result.win_get_url.dest }}" + path: "{{msi_download_path}}" register: win_msi_install_result - name: check win_msi install result @@ -39,10 +39,10 @@ - "not win_msi_install_result|failed" - "win_msi_install_result|changed" -- name: install 7zip msi again with creates argument +- name: install msi again with creates argument win_msi: - path: "{{ win_get_url_result.win_get_url.dest }}" - creates: "C:\\Program Files\\7-Zip" + path: "{{msi_download_path}}" + creates: "{{msi_install_path}}" register: win_msi_install_again_result - name: check win_msi install again result @@ -51,9 +51,9 @@ - "not win_msi_install_again_result|failed" - "not win_msi_install_again_result|changed" -- name: uninstall 7zip msi +- name: uninstall msi win_msi: - path: "{{ win_get_url_result.win_get_url.dest }}" + path: "{{msi_download_path}}" state: absent register: win_msi_uninstall_result