Replace randstr with password plugin in collection tests

This commit is contained in:
Caleb Boylan
2020-01-19 19:15:14 -08:00
parent 4a6db13daa
commit fc80cf5241
6 changed files with 318 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
- name: create a tempdir for hostvars
local_action: shell mktemp -d
register: tempdir
- name: write a file w/ hostvars
local_action:
module: lineinfile
dest: "{{ tempdir.stdout }}/vars"
line: '{"foo": "bar"}'
create: true
- name: Generate an inventory name
set_fact:
inv_name: "inv-for-group-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Create an Inventory
tower_inventory:
name: "{{ inv_name }}"
organization: Default
state: present
- name: Create a Host
tower_host:
name: "some-host"
inventory: "{{ inv_name }}"
state: present
variables: "@{{ tempdir.stdout }}/vars"
register: result
- assert:
that:
- "result is changed"
- name: Delete a Host
tower_host:
name: "some-host"
inventory: "{{ inv_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Check module fails with correct msg
tower_host:
name: test-host
description: Host Description
inventory: test-non-existing-inventory
state: present
register: result
ignore_errors: true
- assert:
that:
- "result.msg =='Failed to update host, inventory not found: The requested object could not be found.'"