Skip to content
Snippets Groups Projects
Commit 6d22972a authored by matt01671's avatar matt01671
Browse files

combined parts

parent c2a6ada2
No related branches found
No related tags found
No related merge requests found
Showing
with 35 additions and 87 deletions
# Executes on all inventory hosts in this pattern
- hosts: localhost
# - hosts: vms <- can select one e.g. vms[0]
vars_files:
- host_vars/nectar.yaml
gather_facts: true
roles:
- role: openstack-common
- role: openstack-images
- role: openstack-volume
- role: openstack-security-group
- role: openstack-instance
- role: openstack-volume-snapshot
\ No newline at end of file
- hosts: COMP90024
vars_files:
- host_vars/wordpress.yaml
gather_facts: true
roles:
- role: wp-common
- role: wp-volumes
- role: wp-docker
- role: wp-wordpress
......@@ -3,13 +3,9 @@ availability_zone: melbourne-qh2-uom
# Volume
volumes:
- vol_name: demo-vol-1-1
- vol_name: demo-03-vol-1
vol_size: 10
- vol_name: demo-vol-1-2
vol_size: 10
- vol_name: demo-vol-2-1
vol_size: 10
- vol_name: demo-vol-2-2
- vol_name: demo-03-vol-2
vol_size: 10
# Security group
......@@ -29,12 +25,9 @@ security_groups:
# Instance
instances:
- name: demo-1
volumes: ['demo-vol-1-1', 'demo-vol-1-2']
- name: demo-2
volumes: ['demo-vol-2-1', 'demo-vol-2-2']
- name: demo-03
volumes: ['demo-03-vol-1', 'demo-03-vol-2']
# NeCTAR Ubuntu 18.04 LTS (Bionic)
instance_image: 45225edb-66d8-4fd0-bf41-132a31a18166
instance_key_name: test-moh
instance_flavor: uom.mse.2c9g
instance_key_name: id_alwyn
instance_flavor: uom.general.1c4g
[COMP90024]
172.26.131.20 ansible_python_interpreter=/usr/bin/python3
172.26.130.73 ansible_python_interpreter=/usr/bin/python3
\ No newline at end of file
[COMP90024:vars]
ansible_python_interpreter=/usr/bin/python3
ansible_user=ubuntu
ansible_ssh_private_key_file=~/.ssh/id_matt
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
- hosts: localhost
vars_files:
- host_vars/nectar.yaml
gather_facts: true
roles:
- role: openstack-remove
\ No newline at end of file
......@@ -7,18 +7,18 @@
state: latest
update_cache: yes
when: ansible_distribution == "Ubuntu"
# Equivalent to: sudo apt-get update; sudo apt-get install python-pip
# sudo apt-get update; sudo apt-get install python-pip
- name: Update pip
become: yes # Pass
become: yes
pip:
name: ['pip']
state: latest
# Equivalent to: pip install --upgrade pip
# pip install --upgrade pip
- name: Install openstacksdk
become: yes
pip:
name: ['openstacksdk']
state: latest
# Equivalent to: pip install openstacksdk
\ No newline at end of file
# pip install openstacksdk
\ No newline at end of file
---
# 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 }}'
......@@ -12,7 +12,7 @@
auto_floating_ip: yes
wait: yes
timeout: 600
state: present # Create VM, absent = delete
state: present
loop: '{{ instances }}'
register: os_instance
......@@ -25,7 +25,7 @@
wait_for:
host: "{{ item.openstack.public_v4 }}"
port: 22
timeout: 240
timeout: 120
search_regex: OpenSSH
loop: '{{ os_instance.results }}'
when: item.openstack is defined
......
---
# Delete an instance on NeCTAR
- name: Remove an instance
os_server:
name: '{{ item.name }}'
state: absent
timeout: 600
loop: '{{ instances }}'
---
# Create volume snapshot(s)
- name: Create volume snapshot(s)
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
timeout: 600
force: yes
availability_zone: '{{ availability_zone }}'
loop: '{{ volumes }}'
\ No newline at end of file
version: '3.6'
version: '3.7'
services:
wordpress:
......
#!/bin/bash
#!/usr/bin/env bash
. ./unimelb-comp90024-2020-grp-62-openrc.sh; ansible-playbook -i hosts -u ubuntu --key-file=~/.ssh/id_matt remove.yaml
\ No newline at end of file
. ./unimelb-comp90024-2020-grp-62-openrc.sh; ansible-playbook -i hosts --ask-become-pass all-in-one.yaml
\ No newline at end of file
#!/bin/bash
# Check format
#ansible-lint
# checkout a repo of configuration instructions from git,
# and then run ansible-playbook against that content.
#ansible-pull
# --ask-beome-pass = ask sudo user password
. ./unimelb-comp90024-2020-grp-62-openrc.sh; ansible-playbook --ask-become-pass nectar.yaml
#. ./openrc.sh; ansible-playbook -i hosts -u ubuntu --key-file=~/.ssh/id_matt wordpress.yaml
\ No newline at end of file
#!/bin/bash
. ./unimelb-comp90024-2020-grp-62-openrc.sh; ansible-playbook -i hosts -u ubuntu --key-file=~/.ssh/id_matt wordpress.yaml
\ 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