Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 1 | --- |
| 2 | # cord-profile/tasks/main.yml |
| 3 | # Constructs a CORD service profile directory and configuration files |
| 4 | |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 5 | - name: Create and copy XOS admin password |
| 6 | copy: |
| 7 | content: "{{ xos_admin_pass }}" |
| 8 | dest: "{{ cord_dir }}/build/platform-install/credentials/{{ xos_admin_user }}" |
| 9 | |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 10 | - name: Create cord_profile directory |
| 11 | become: yes |
| 12 | file: |
| 13 | path: "{{ cord_profile_dir }}" |
| 14 | state: directory |
| 15 | mode: 0755 |
| 16 | owner: "{{ ansible_user_id }}" |
| 17 | group: "{{ ansible_user_gid }}" |
| 18 | |
Zack Williams | 2478b30 | 2017-02-14 10:42:55 -0700 | [diff] [blame] | 19 | - name: Create cord_profile/profile_name with the name of the profile |
| 20 | copy: |
| 21 | dest: "{{ cord_profile_dir }}/profile_name" |
| 22 | content: "{{ cord_profile }}" |
| 23 | mode: 0644 |
| 24 | |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 25 | - name: Create subdirectories inside cord_profile directory |
| 26 | file: |
| 27 | path: "{{ cord_profile_dir }}/{{ item }}" |
| 28 | state: directory |
| 29 | mode: 0755 |
| 30 | with_items: |
| 31 | - key_import |
| 32 | - onboarding-docker-compose |
| 33 | - images |
| 34 | |
Andy Bavier | 1ff4b48 | 2017-03-24 09:20:36 -0400 | [diff] [blame] | 35 | # *** This should be revisited. *** |
| 36 | # Currently the key pair is generated on the head node by the |
| 37 | # "prep" role in the "maas" repo, invoked during the "deployBase" Gradle task. |
| 38 | # The keys should probably be generated earlier, in the corddev VM, and copied over. |
| 39 | # The /opt/credentials directory might be a good place to keep the generated keys. |
| 40 | # |
| 41 | # Ensure a keypair exists in case we're not running on MaaS. |
| 42 | - name: Ensure keypair |
| 43 | user: |
| 44 | name: "{{ ansible_user_id }}" |
| 45 | generate_ssh_key: yes |
| 46 | |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 47 | - name: Copy ssh keys to key_import directory |
| 48 | copy: |
Andy Bavier | 4b490d7 | 2017-03-25 07:59:21 -0400 | [diff] [blame] | 49 | # 'expanduser' won't work below, it expands on control machine |
Andy Bavier | 53b03f6 | 2017-03-25 11:42:23 -0400 | [diff] [blame] | 50 | src: "{{ item.source_path | replace('~', ansible_user_dir, 1) }}" |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 51 | dest: "{{ cord_profile_dir }}/key_import/{{ item.name }}" |
| 52 | mode: 0600 |
Andy Bavier | 1ff4b48 | 2017-03-24 09:20:36 -0400 | [diff] [blame] | 53 | remote_src: True |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 54 | with_items: "{{ xos_service_sshkeys }}" |
| 55 | |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 56 | - name: Copy cert chain and core api key and cert |
Andy Bavier | f0b5d7d | 2017-03-15 16:19:03 -0400 | [diff] [blame] | 57 | copy: |
| 58 | src: "{{ pki_dir }}/{{ item }}" |
| 59 | dest: "{{ cord_profile_dir }}/{{ item }}" |
| 60 | mode: 0600 |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 61 | remote_src: True |
Andy Bavier | f0b5d7d | 2017-03-15 16:19:03 -0400 | [diff] [blame] | 62 | with_items: |
| 63 | - core_api_key.pem |
| 64 | - core_api_cert.pem |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 65 | - im_cert_chain.pem |
Andy Bavier | f0b5d7d | 2017-03-15 16:19:03 -0400 | [diff] [blame] | 66 | |
Andy Bavier | 53b03f6 | 2017-03-25 11:42:23 -0400 | [diff] [blame] | 67 | - name: Get localhost facts (to get local uid and gid) |
| 68 | setup: |
| 69 | delegate_to: localhost |
| 70 | delegate_facts: True |
| 71 | |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 72 | - name: Make local images directory |
| 73 | delegate_to: localhost |
Zack Williams | c6ff6b3 | 2017-02-10 16:35:29 -0700 | [diff] [blame] | 74 | become: yes |
| 75 | file: |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 76 | path: "{{ image_dir }}" |
Zack Williams | c6ff6b3 | 2017-02-10 16:35:29 -0700 | [diff] [blame] | 77 | state: directory |
| 78 | mode: 0755 |
Andy Bavier | 53b03f6 | 2017-03-25 11:42:23 -0400 | [diff] [blame] | 79 | owner: "{{ hostvars['localhost']['ansible_user_id'] }}" |
| 80 | group: "{{ hostvars['localhost']['ansible_user_gid'] }}" |
Zack Williams | c6ff6b3 | 2017-02-10 16:35:29 -0700 | [diff] [blame] | 81 | |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 82 | - name: Download Glance VM images |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 83 | when: use_openstack |
| 84 | delegate_to: localhost |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 85 | get_url: |
| 86 | url: "{{ item.url }}" |
| 87 | checksum: "{{ item.checksum }}" |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 88 | dest: "{{ image_dir }}/{{ item.name }}.qcow2" |
Zack Williams | c6ff6b3 | 2017-02-10 16:35:29 -0700 | [diff] [blame] | 89 | with_items: "{{ xos_images }}" |
Zack Williams | 275e48b | 2017-03-24 12:16:00 -0700 | [diff] [blame] | 90 | register: glance_vm_result |
| 91 | until: glance_vm_result|success |
| 92 | retries: 5 |
| 93 | delay: 10 |
Zack Williams | c6ff6b3 | 2017-02-10 16:35:29 -0700 | [diff] [blame] | 94 | |
| 95 | - name: Copy Glance VM images to profile directory |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 96 | when: use_openstack |
Zack Williams | c6ff6b3 | 2017-02-10 16:35:29 -0700 | [diff] [blame] | 97 | copy: |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 98 | src: "{{ image_dir }}/{{ item.name }}.qcow2" |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 99 | dest: "{{ cord_profile_dir }}/images/{{ item.name }}.qcow2" |
| 100 | with_items: "{{ xos_images }}" |
| 101 | |
| 102 | - name: Copy over commonly used and utility TOSCA files |
| 103 | copy: |
| 104 | src: "{{ item }}" |
| 105 | dest: "{{ cord_profile_dir }}/{{ item }}" |
| 106 | with_items: |
| 107 | - fixtures.yaml |
| 108 | - enable-onboarding.yaml |
| 109 | - disable-onboarding.yaml |
| 110 | |
| 111 | - name: Create templated XOS configuration files |
| 112 | template: |
| 113 | src: "{{ item }}.j2" |
| 114 | dest: "{{ cord_profile_dir }}/{{ item }}" |
| 115 | mode: 0644 |
| 116 | with_items: |
| 117 | - xos_common_config |
| 118 | - deployment.yaml |
| 119 | - xos.yaml |
Scott Baker | 970f24b | 2017-02-13 14:16:40 -0800 | [diff] [blame] | 120 | - gateway-config.yml |
Matteo Scandolo | 667334f | 2017-02-26 10:58:08 -0800 | [diff] [blame] | 121 | - style.config.js |
| 122 | - app.config.js |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 123 | - Dockerfile.xos |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 124 | - xos-gui-extensions.yml |
Andy Bavier | 9e7d54a | 2017-04-17 11:37:02 -0400 | [diff] [blame] | 125 | - docker-compose.yml |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 126 | |
| 127 | - name: Create profile specific templated TOSCA config files |
| 128 | template: |
| 129 | src: "{{ item }}.j2" |
| 130 | dest: "{{ cord_profile_dir }}/{{ item }}" |
| 131 | with_items: "{{ xos_tosca_config_templates }}" |
| 132 | |
| 133 | - name: Create profile specific templated non-TOSCA files |
| 134 | template: |
| 135 | src: "{{ item }}.j2" |
| 136 | dest: "{{ cord_profile_dir }}/{{ item }}" |
| 137 | with_items: "{{ xos_other_templates }}" |
| 138 | |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 139 | - name: Copy node key |
| 140 | when: not on_maas and use_openstack |
Zack Williams | a276311 | 2017-01-03 11:38:38 -0700 | [diff] [blame] | 141 | copy: |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 142 | src: "{{ ansible_user_dir }}/.ssh/id_rsa" |
| 143 | dest: "{{ item }}/node_key" |
| 144 | owner: "{{ ansible_user }}" |
Zack Williams | 2a5f686 | 2017-02-09 16:39:52 -0700 | [diff] [blame] | 145 | mode: 0600 |
Andy Bavier | 1ff4b48 | 2017-03-24 09:20:36 -0400 | [diff] [blame] | 146 | remote_src: True |
Andy Bavier | a6cffe1 | 2017-03-15 17:33:42 -0400 | [diff] [blame] | 147 | with_items: |
| 148 | - "{{ ansible_user_dir }}" |
| 149 | - "{{ cord_profile_dir }}" |
| 150 | |
| 151 | - name: Copy node key (MaaS) |
| 152 | when: on_maas and use_openstack |
| 153 | become: yes |
| 154 | copy: |
| 155 | src: "{{ maas_node_key }}" |
| 156 | dest: "{{ item }}/node_key" |
| 157 | owner: "{{ ansible_user }}" |
| 158 | mode: 0600 |
| 159 | remote_src: True |
| 160 | with_items: |
| 161 | - "{{ ansible_user_dir }}" |
| 162 | - "{{ cord_profile_dir }}" |