interop-workloads/workloads/ansible/shade/lampstack/roles/prepare/tasks/apply.yml

101 lines
3.1 KiB
YAML
Executable File

---
- name: Ensure we have a working directory to save runtime files
file: "path={{ playbook_dir }}/run state=directory"
- name: Retrieve specified flavor
os_flavor_facts:
auth: "{{ auth }}"
region_name: "{{ app_env.region_name }}"
availability_zone: "{{ app_env.availability_zone }}"
validate_certs: "{{ app_env.validate_certs }}"
name: "{{ app_env.flavor_name }}"
- name: Create a key-pair
os_keypair:
state: "present"
auth: "{{ auth }}"
region_name: "{{ app_env.region_name }}"
availability_zone: "{{ app_env.availability_zone }}"
validate_certs: "{{ app_env.validate_certs }}"
name: "lampstack"
public_key_file: "{{ app_env.public_key_file }}"
- name: Create volume
os_volume:
state: present
auth: "{{ auth }}"
region_name: "{{ app_env.region_name }}"
availability_zone: "{{ app_env.availability_zone }}"
validate_certs: "{{ app_env.validate_certs }}"
size: "{{ app_env.volume_size }}"
wait: yes
display_name: db_volume
- name: Create security group
os_security_group:
state: present
auth: "{{ auth }}"
region_name: "{{ app_env.region_name }}"
availability_zone: "{{ app_env.availability_zone }}"
validate_certs: "{{ app_env.validate_certs }}"
name: lampstack_sg
description: security group for lampstack
- name: Add security rules
os_security_group_rule:
state: present
auth: "{{ auth }}"
region_name: "{{ app_env.region_name }}"
availability_zone: "{{ app_env.availability_zone }}"
validate_certs: "{{ app_env.validate_certs }}"
security_group: lampstack_sg
protocol: "{{ item.protocol }}"
direction: "{{ item.dir }}"
port_range_min: "{{ item.p_min }}"
port_range_max: "{{ item.p_max }}"
remote_ip_prefix: 0.0.0.0/0
with_items:
- { p_min: 22, p_max: 22, dir: ingress, protocol: tcp }
- { p_min: 80, p_max: 80, dir: ingress, protocol: tcp }
- { p_min: 2049, p_max: 2049, dir: ingress, protocol: tcp }
- { p_min: 2049, p_max: 2049, dir: egress, protocol: tcp }
- { p_min: 3306, p_max: 3306, dir: ingress, protocol: tcp }
- { p_min: -1, p_max: -1, dir: ingress, protocol: icmp }
- { p_min: -1, p_max: -1, dir: egress, protocol: icmp }
- name: Create volume
os_volume:
state: present
auth: "{{ auth }}"
region_name: "{{ app_env.region_name }}"
availability_zone: "{{ app_env.availability_zone }}"
validate_certs: "{{ app_env.validate_certs }}"
size: "{{ app_env.volume_size }}"
wait: yes
display_name: db_volume
- name: Add database node to provisioning host group
add_host:
name: "database"
targetgroup: "dbservers"
ansible_host: "127.0.0.1"
groups: "prohosts"
no_log: True
- name: Add balancer node to provisioning host group
add_host:
name: "balancer"
targetgroup: "balancers"
ansible_host: "127.0.0.1"
groups: "prohosts"
no_log: True
- name: Add apache nodes to provisioning host group
add_host:
name: "apache-{{ item }}"
targetgroup: "webservers"
ansible_host: "127.0.0.1"
groups: "prohosts"
with_sequence: count={{ app_env.stack_size - 2 }}
no_log: True