blob: 1ec3229b6df36f1875f6faa89fafd697cbc272c1 [file] [log] [blame]
# 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
- name: add header to hosts file
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
- 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
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
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
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
- lineinfile: line="{{ groups['registry'] | first }} whisk-registry" dest=/etc/hosts
become: true
- name: Install git on registry
hosts: registry
- apt: update_cache=yes
become: true
- package: name=git
become: true