#!/usr/bin/ansible-playbook --module-path=../../../library/ --- - hosts: "{{ cli_master_test }}" gather_facts: no user: root vars_prompt: - name: cli_master_test prompt: "Master to run against" private: false default: localhost vars: secret_name: secret-int-test ns_name: default config_path: "/tmp/{{ secret_name }}--config.yml" passwords_path: "/tmp/{{ secret_name }}--passwords.yml" post_tasks: - name: Setup our files to test with copy: dest: "{{ item.name }}" content: "{{ item.content }}" with_items: - name: "{{ config_path }}" content: | value: True - name: "{{ passwords_path }}" content: | test1 test2 test3 test4 - name: Make sure we're starting with a clean slate oc_secret: state: absent namespace: "{{ ns_name }}" name: "{{ secret_name }}" register: secret_out - name: Test adding a secret - Act oc_secret: state: present namespace: "{{ ns_name }}" name: "{{ secret_name }}" files: - name: config.yml path: "{{ config_path }}" - name: passwords.yml path: "{{ passwords_path }}" register: secret_out - name: Test adding a secret - Assert assert: that: - "secret_out.results.returncode == 0" - "secret_out.changed == True" - name: Test secret present idempotentcy - Act oc_secret: state: present namespace: "{{ ns_name }}" name: "{{ secret_name }}" files: - name: config.yml path: "{{ config_path }}" - name: passwords.yml path: "{{ passwords_path }}" register: secret_out - name: Test secret present idempotentcy - Assert assert: that: - "secret_out.changed == false" - name: Test list secrets - Act oc_secret: state: list namespace: "{{ ns_name }}" name: "{{ secret_name }}" register: secret_out - name: Test list secrets - Assert assert: that: - "secret_out.changed == false" - "secret_out.results.exists == true" - name: Test secret absent - Act oc_secret: state: absent namespace: "{{ ns_name }}" name: "{{ secret_name }}" register: secret_out - name: Test secret absent - Assert assert: that: - "secret_out.changed == true" - "secret_out.results.returncode == 0" - name: Test secret absent idempotentcy - Act oc_secret: state: absent namespace: "{{ ns_name }}" name: "{{ secret_name }}" register: secret_out - name: Test secret idempotentcy - Assert assert: that: - "secret_out.changed == false" - name: Clean up the files we created file: state: absent path: "{{ item }}" with_items: - "/tmp/{{ secret_name }}--config.yml" - "/tmp/{{ secret_name }}--passwords.yml"