From 358c759bd9a5ff5b5c70576b690ffd255a07c9cb Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Fri, 15 Jun 2018 09:55:21 +0200 Subject: [PATCH] test: manual tower projects don't require creds --- .../tasks/create_project_dir.yml | 49 +++++++++++++++++++ .../targets/tower_project/tasks/main.yml | 15 ++++++ 2 files changed, 64 insertions(+) create mode 100644 test/integration/targets/tower_project/tasks/create_project_dir.yml diff --git a/test/integration/targets/tower_project/tasks/create_project_dir.yml b/test/integration/targets/tower_project/tasks/create_project_dir.yml new file mode 100644 index 00000000000..0777ad29b51 --- /dev/null +++ b/test/integration/targets/tower_project/tasks/create_project_dir.yml @@ -0,0 +1,49 @@ +- name: Fetch project_base_dir + uri: + url: "https://{{ lookup('env', 'TOWER_HOST') }}/api/v2/config/" + user: "{{ lookup('env', 'TOWER_USERNAME') }}" + password: "{{ lookup('env', 'TOWER_PASSWORD') }}" + validate_certs: false + return_content: true + register: awx_config + +- tower_inventory: + name: localhost + organization: Default + +- tower_host: + name: localhost + inventory: localhost + variables: + ansible_connection: local + +- name: Create a private key (which will not be used) + copy: + content: | + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIIUl6R1xgzR6siIUArz4XBPtGZ09aetma2eWf1v3uYymoAoGCCqGSM49 + AwEHoUQDQgAENJNjgeZDAh/+BY860s0yqrLDprXJflY0GvHIr7lX3ieCtrzOMCVU + QWzw35pc5tvuP34SSi0ZE1E+7cVMDDOF3w== + -----END EC PRIVATE KEY----- + dest: "{{ output_dir }}/tower_project_unused_key" + +- name: create an unused SSH / Machine credential + tower_credential: + name: dummy + kind: ssh + ssh_key_data: "{{ output_dir }}/tower_project_unused_key" + organization: Default + +- name: Disable bubblewrap + command: tower-cli setting modify AWX_PROOT_ENABLED false + +- block: + - name: Create a directory for manual project + vars: + project_base_dir: "{{ awx_config.json.project_base_dir }}" + command: tower-cli ad_hoc launch --monitor --inventory localhost + --credential dummy --module-name command + --module-args "mkdir {{ project_base_dir }}/manual_test_project" + always: + - name: enable bubblewrap + command: tower-cli setting modify AWX_PROOT_ENABLED true diff --git a/test/integration/targets/tower_project/tasks/main.yml b/test/integration/targets/tower_project/tasks/main.yml index 0353977003c..116cf967d1a 100644 --- a/test/integration/targets/tower_project/tasks/main.yml +++ b/test/integration/targets/tower_project/tasks/main.yml @@ -25,3 +25,18 @@ - assert: that: - "result is changed" + +- name: create a project directory for manual project + import_tasks: create_project_dir.yml + +- name: Create a manual project + tower_project: + name: manual project + organization: Default + scm_type: manual + local_path: "manual_test_project" + register: result + +- assert: + that: + - "result is changed"