--- - name: Ensure a test project exists hosts: controllers[0] vars: venv: "{{ ansible_env.PWD }}/shade-venv" # Dict of quotas to set for the test project. test_project_quotas: cores: -1 floating_ips: -1 injected_files: -1 injected_file_size: -1 instances: -1 key_pairs: -1 fixed_ips: -1 ram: -1 secgroup_rules: -1 secgroups: -1 test_ssh_private_key_path: "{{ ansible_env.PWD ~ '/.ssh/id_rsa' }}" test_ssh_public_key_path: "{{ test_ssh_private_key_path ~ '.pub' }}" test_ssh_key_type: rsa pre_tasks: - name: Validate OpenStack password authentication parameters fail: msg: > Required OpenStack authentication parameter {{ item }} is {% if item in openstack_auth %}empty{% else %}not present{% endif %} in openstack_auth. Have you sourced the environment file? when: - "{{ openstack_auth_type == 'password' }}" - "{{ item not in openstack_auth or not openstack_auth[item] }}" with_items: "{{ openstack_auth_password_required_params }}" tags: - config-validation - name: Check whether an SSH key exists on the controller stat: path: "{{ test_ssh_private_key_path }}" register: ssh_key_stat - name: Generate an SSH key on the controller command: ssh-keygen -t {{ test_ssh_key_type }} -N '' -f {{ test_ssh_private_key_path }} when: not ssh_key_stat.stat.exists - name: Read the SSH public key on the controller slurp: src: "{{ test_ssh_public_key_path }}" register: ssh_public_key roles: - role: test-project test_project_venv: "{{ venv }}" test_project_auth_type: "{{ openstack_auth_type }}" test_project_admin_auth: "{{ openstack_auth }}" test_project_openrc_directory: "{{ kayobe_config_path }}" test_project_public_key: "{{ ssh_public_key.content | b64decode }}" - role: openstackclient openstackclient_venv: "{{ venv }}" post_tasks: - name: Ensure quotas are set shell: > source {{ venv }}/bin/activate && openstack quota set {{ test_project_name }} {% for name, value in test_project_quotas.items() %} --{{ name | replace('_', '-') }}={{ value }}{% endfor %} when: "{{ test_project_quotas }}" environment: "{{ openstack_auth_env }}"