| # Licensed to the Apache Software Foundation (ASF) under one or more contributor |
| # license agreements; and to You under the Apache License, Version 2.0. |
| --- |
| # provision_env.yml |
| - name: create instances and hosts file |
| hosts: ansible |
| tasks: |
| - name: add header to hosts file |
| copy: |
| content: "; the first parameter in a host is the inventory_hostname\n\nansible ansible_connection=local\n" |
| dest: "{{hosts_dir}}/hosts" |
| |
| - name: Create instances |
| import_tasks: boot_instances_dist.yml instance={{item}} |
| with_items: instances |
| |
| - meta: refresh_inventory |
| |
| # TODO, add support to loop through instances, configure all vms that have cinder disks (kafka, elk, etc). Hardcoding to db for now |
| - name: Configure couch db disks |
| hosts: db |
| tasks: |
| - name: Ensure VM is up and running before starting disk configuration |
| wait_for: host={{ansible_default_ipv4.address}} port=22 |
| - name: Get list of configured disks |
| shell: df -h |
| register: disks |
| - name: Check to see if volume size has been set via env or group_vars |
| set_fact: |
| volume_env: "{{lookup('env', 'OS_WSK_DB_VOLUME')}}" |
| instance: "{{instances | selectattr('name', 'equalto', 'db') | list | first}}" |
| - name: Set boolean flag to determine if volume is to be configured or not. Skip if volume value is not set in both env and group_vars, or if it has already been configured |
| set_fact: |
| configure_volume: "{{(volume_env is defined and volume_env != '') or |
| ((instance.volume) and (instance.volume.fsmount and instance.volume.fsmount not in disks.stdout))}}" |
| - name: Get fsmount/fstype params |
| set_fact: |
| fsmount: "{{ instance.volume.fsmount | default('/mnt/' + group_names|first, true ) }}" |
| fstype: "{{ instance.volume.fstype | default('ext4', true) }}" |
| - name: Create mount folder |
| shell: mkdir -p {{ fsmount }} |
| become: true |
| when: configure_volume and (fsmount not in disks.stdout) |
| - name: Partition persistent disk |
| shell: mkfs.{{ fstype }} {{ block_device }} 2>/dev/null |
| become: true |
| when: configure_volume and (fsmount not in disks.stdout) |
| - name: Mount persistent disk |
| shell: mount -t {{ fstype }} {{ block_device }} {{ fsmount }} |
| # - mount: name={{fsmount}} src={{device}} fstype={{fstype}} state=present # TODO, mount module not working as expected |
| become: true |
| when: configure_volume and (fsmount not in disks.stdout) |
| |
| - name: append registry url to hosts file |
| hosts: all:!ansible |
| tasks: |
| - lineinfile: line="{{ groups['registry'] | first }} whisk-registry" dest=/etc/hosts |
| become: true |
| |
| - name: Install git on registry |
| hosts: registry |
| tasks: |
| - apt: update_cache=yes |
| become: true |
| - package: name=git |
| become: true |