summaryrefslogtreecommitdiffstats
path: root/tools/cicdansible/roles/install/tasks/install.yml
blob: 529e2acf334a3424c3299e9d721c8ccb8b198f3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#Onap installation tasks
#Copy ssh private key used for resource server access
- name: "Copy resource server access key"
  copy:
    src: "{{ hostvars[groups['resources'][0]].ansible_private_key_file }}"
    dest: "{{ ansible_user_dir }}/.ssh/res.pem"
    mode: 0600
#Unarchive resources.
- name: "Ensure {{ installer_deploy_path }} directory exists"
  file:
    path: "{{ installer_deploy_path }}"
    state: directory
- name: "Extract sw resources"
  unarchive:
    src: "resources/{{ hostvars[groups['resources'][0]].resources_sw_filename }}"
    dest: "{{ installer_deploy_path }}"
#Generate ansible inventory and extra vars.
- name: "Generate ansible inventory for installer"
  template:
    src: inventory.yml.j2
    dest: "{{ installer_deploy_path }}/ansible/inventory/hosts.yml"
- name: "generate application specific config overrides"
  copy:
    content: "{{ application_config | b64decode }}"
    dest: "{{ installer_deploy_path }}/ansible/application/application_overrides.yml"
  # add onap network configuration to overrides
- name: "inject onap network information to config overrides"
  replace:
    path: "{{ installer_deploy_path }}/ansible/application/application_overrides.yml"
    regexp: '({{ item.key }}:)\s?.*'
    replace: '\1 {{ item.value }}'
  loop: "{{ lines|dict2items }}"
  vars:
    lines:
      openStackPrivateNetId: "{{ (hostvars['localhost'].heat_stack.stack.outputs | selectattr('output_key', 'equalto', 'network_id') | list).0.output_value }}"
      openStackPrivateSubnetId: "{{ (hostvars['localhost'].heat_stack.stack.outputs | selectattr('output_key', 'equalto', 'subnet_id') | list).0.output_value }}"
# This generates a file with locations of resource files in resource host, we
# do it only to allow manually running offline installer without
# typing them by hand. We cannot use
# inventory template because it will be overridden
# by application_configuration.yml.
- name: Generate resource location file
  copy:
    content: |
      resources_dir: {{ resources_dir }}
      resources_filename: {{ resources_filename }}
      aux_resources_filename: {{ aux_resources_filename }}
      app_data_path: /opt/onap/resources
    dest: "{{ installer_deploy_path }}/ansible/application/resources.yml"
#Run script.
- name: "Execute installation"
  shell:
    ./run_playbook.sh
     -e @application/application_configuration.yml -e @application/application_overrides.yml
     -e @application/resources.yml -i inventory/hosts.yml site.yml
  args:
    chdir: "{{ installer_deploy_path }}/ansible"
  async: "{{ install_timeout }}"
  when: install_app | bool