Skip to content
Snippets Groups Projects
Commit 11ea8db4 authored by Diego Alejandro Arias Rodriguez's avatar Diego Alejandro Arias Rodriguez
Browse files

Ansible couch

parent 39adba54
No related branches found
No related tags found
No related merge requests found
Showing
with 160 additions and 0 deletions
- name: Bind the clustered interface to all IP addresses availble on this machine
command: curl -X PUT http://{{ database_user }}:{{ database_password }}@127.0.0.1:5984/_node/_local/_config/chttpd/bind_address -d '"0.0.0.0"'
- name: Bind the clustered interface to all IP addresses availble on this machine
command: curl -X PUT http://{{ database_user }}:{{ database_password }}@127.0.0.1:5984/_node/_local/_config/httpd/bind_address -d '"0.0.0.0"'
- name: Set the UUID of the node to
command: curl -X PUT http://{{ database_user }}:{{ database_password }}@127.0.0.1:5984/_node/_local/_config/couchdb/uuid -d '"{{ database_uuid }}"'
- name: Set the shared http secret for cookie creation
command: curl -X PUT http://{{ database_user }}:{{ database_password }}@127.0.0.1:5984/_node/_local/_config/couch_httpd_auth/secret -d '"{{ database_secret }}"
\ No newline at end of file
File added
# Show all available Openstack images
- name: Retrieve all available Openstack images
os_image_info:
register: image_result
- name: Get image names and Ids
set_fact:
image_facts: "{{ image_facts|default([]) + [ {'name': item.name, 'id': item.id} ] }}"
loop: '{{ image_result.openstack_image }}'
when: item.name is defined
- name: Show images
debug:
msg: "Image name: {{ item.name }}; Image id: {{ item.id }}"
loop: '{{ image_facts }}'
File added
---
# Create an instance on MRC
- name: Create an instance
os_server:
name: '{{ item.name }}'
image: '{{ instance_image }}'
key_name: '{{ instance_key_name }}'
flavor: '{{ instance_flavor }}'
availability_zone: '{{ availability_zone }}'
security_groups: '{{ sg_names }}'
volumes: '{{ item.volumes }}'
auto_floating_ip: yes
wait: yes
timeout: 600
state: present
loop: '{{ instances }}'
register: os_instance
- debug:
msg: "Instance {{ item.openstack.name }} has been created. IP address is {{ item.openstack.public_v4 }}"
loop: '{{ os_instance.results }}'
when: item.openstack is defined
- name: Wait for connection
wait_for:
host: "{{ item.openstack.public_v4 }}"
port: 22
timeout: 240
search_regex: OpenSSH
loop: '{{ os_instance.results }}'
when: item.openstack is defined
\ No newline at end of file
File added
---
# Create a security group
- name: Create a security group
os_security_group:
name: '{{ item.name }}'
description: '{{ item.description }}'
state: present
loop: '{{ security_groups }}'
- name: Create a list of security group names
set_fact:
sg_names: '{{ sg_names|default([]) + [ item.name ] }}'
loop: '{{ security_groups }}'
- debug:
msg: "Security group(s) {{ sg_names }} have been created."
# Create security group rules
- name: Create security group rules
os_security_group_rule:
security_group: '{{ item.name }}'
protocol: '{{ item.protocol }}'
port_range_min: '{{ item.port_range_min }}'
port_range_max: '{{ item.port_range_max }}'
remote_ip_prefix: '{{ item.remote_ip_prefix }}'
state: present
loop: '{{ security_groups }}'
\ No newline at end of file
File added
---
# create volume snapshot
- name: Create volume snapshot
os_volume_snapshot:
state: present
volume: '{{ item.vol_name }}'
display_name: "{{ item.vol_name }}-{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
wait: yes # wait until the snapshot is created
timeout: 600
force: yes
availability_zone: '{{ availability_zone }}'
loop: '{{ volumes }}'
\ No newline at end of file
---
# Create volumes from vars
- name: Create volume(s) on NeCTAR
os_volume:
display_name: '{{ item.vol_name }}'
size: '{{ item.vol_size }}'
availability_zone: '{{ availability_zone }}'
wait: yes
timeout: 600
state: present
loop: '{{ volumes }}'
register: os_vol
# Get a list of volume Ids from the reutrn value of os_volume
- name: Create a list of volume Ids
set_fact:
os_vol_ids: '{{ os_vol_ids|default([]) + [ item.id ] }}'
loop: '{{ os_vol.results }}'
- debug:
msg: "Volume {{ os_vol_ids }} has been created"
\ No newline at end of file
. ./unimelb-comp90024-2021-grp-62-openrc.sh; ansible-playbook mrc.yaml
#!/usr/bin/env bash
# To use an OpenStack cloud you need to authenticate against the Identity
# service named keystone, which returns a **Token** and **Service Catalog**.
# The catalog contains the endpoints for all services the user/tenant has
# access to - such as Compute, Image Service, Identity, Object Storage, Block
# Storage, and Networking (code-named nova, glance, keystone, swift,
# cinder, and neutron).
#
# *NOTE*: Using the 3 *Identity API* does not necessarily mean any other
# OpenStack API is version 3. For example, your cloud provider may implement
# Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is
# only for the Identity API served through keystone.
export OS_AUTH_URL=https://keystone.rc.nectar.org.au:5000/v3/
# With the addition of Keystone we have standardized on the term **project**
# as the entity that owns the resources.
export OS_PROJECT_ID=c82f39882d974dbf8b5c925fb3eb4448
export OS_PROJECT_NAME="unimelb-comp90024-2021-grp-62"
export OS_USER_DOMAIN_NAME="Default"
if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi
export OS_PROJECT_DOMAIN_ID="default"
if [ -z "$OS_PROJECT_DOMAIN_ID" ]; then unset OS_PROJECT_DOMAIN_ID; fi
# unset v2.0 items in case set
unset OS_TENANT_ID
unset OS_TENANT_NAME
# In addition to the owning entity (tenant), OpenStack stores the entity
# performing the action as the **user**.
export OS_USERNAME="alejandro.ariasrodriguez@student.unimelb.edu.au"
# With Keystone you pass the keystone password.
echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as user $OS_USERNAME: "
#read -sr OS_PASSWORD_INPUT
export OS_PASSWORD='NmQ0Y2IyOTkwOGIwZTQw'
# If your configuration has multiple regions, we set that information here.
# OS_REGION_NAME is optional and only valid in certain environments.
export OS_REGION_NAME="Melbourne"
# Don't leave a blank variable, unset it if it was empty
if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment