Skip to content

Instantly share code, notes, and snippets.

@jsm222
Last active October 7, 2020 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsm222/352ea6fe7ae4446bed39ed788d738827 to your computer and use it in GitHub Desktop.
Save jsm222/352ea6fe7ae4446bed39ed788d738827 to your computer and use it in GitHub Desktop.
---
- hosts: localhost
vars:
network: "private"
tasks:
- name : Create security group webservers
openstack.cloud.security_group:
cloud: {{cloud}}
state: present
name: webservers
description: security group for foo servers
- name: Allow port 80 access
openstack.cloud.security_group_rule:
cloud: {{ cloud }}
security_group: webservers
protocol: tcp
port_range_min: 80
port_range_max: 80
remote_ip_prefix: 0.0.0.0/0
- name: Create a cirros server that acts as simple webserver
openstack.cloud.server:
cloud: {{ cloud }}
state: present
name: "cirros01"
image: "{{ image }}"
flavor: "{{ flavor }}"
security_groups:
- default
- webservers
network: "{{network}}"
auto_floating_ip: false
wait: true
userdata: "#!/bin/sh\n MYIP=$(ifconfig eth0|grep 'inet addr'|awk -F: '{print $2}'| awk '{print $1}'); while true; do echo -e \"HTTP/1.0 200 OK\\r\\n\\r\\nWelcome to $MYIP\" | sudo nc -l -p 80 ; done&"
register: server
- name: print
debug:
msg: "{{ server.openstack.addresses[network][0].addr }}"
- name: "Create load balancer"
openstack.cloud.loadbalancer:
name: lbtest
state: present
vip_subnet: "private-subnet"
auto_public_ip: yes
public_network: public
listeners:
- name: listener01_80
protocol: HTTP
protocol_port: 80
pool:
name: pool01
protocol: HTTP
members:
- name: cirros01
address: "{{ server.openstack.addresses[network][0].addr }}"
protocol_port: 80
subnet: "shared-subnet"
wait: yes
timeout: 1200
register: lb
- name: print
debug:
msg: "{{ lb }}"
- name: "Create health monitor"
openstack.cloud.lb_health_monitor:
cloud: "{{ cloud }}"
wait: true
admin_state_up: True
expected_codes: '200'
max_retries_down: '4'
http_method: GET
url_path: "/"
pool: "{{ lb.loadbalancer.pools[0].id }}"
name: 'test_health_monitor'
delay: '15'
max_retries: '3'
resp_timeout: '10'
state: present
register: result
- name: print
debug:
msg: "{{ result.health_monitor }}"
@jsm222
Copy link
Author

jsm222 commented Sep 27, 2020

This is a draft for a playbook that should do some CI octavia tests for ansible-collections-openstack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment