Commit deb13c3b authored by Daniel Buøy-Vehn's avatar Daniel Buøy-Vehn

Working on openstack deployment via ansible

parent 78d402c6
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDulvvkPEmnEDr+PYXE6eDnTxbb/JApYIhR7XD/xFQWt+pIhFrT/xkAO5iD0fUdS8mOMPurdOPUw0TeTByQgEpGV2LiW+XOFFjZUsF/z9wgC42XmtkJJ7SAlzPMC6zsyCcYZXpXnF4KaMkUme0VJ4rGJMVDZ/DWQX55uq4/SS+OedobXJzOsFs0kvTTvaX7+E8vqs/nutTOw5sSVWRuETSb2b49md9tzC1AqmUK115NP5fjwUNcHfvJ/HsuKYUI7/DCfzDClekDMeyCo2dYvvN0kVdftDtcUfW+nFZEHLj2giS5J9GCpkKrb7orMIvKN5GGgrxjvA8wB/U46qXoe/Ap ansbile@tower01.tower.demo.redpill-linpro.com
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDulvvkPEmnEDr+PYXE6eDnTxbb/JApYIhR7XD/xFQWt+pIhFrT/xkAO5iD0fUdS8mOMPurdOPUw0TeTByQgEpGV2LiW+XOFFjZUsF/z9wgC42XmtkJJ7SAlzPMC6zsyCcYZXpXnF4KaMkUme0VJ4rGJMVDZ/DWQX55uq4/SS+OedobXJzOsFs0kvTTvaX7+E8vqs/nutTOw5sSVWRuETSb2b49md9tzC1AqmUK115NP5fjwUNcHfvJ/HsuKYUI7/DCfzDClekDMeyCo2dYvvN0kVdftDtcUfW+nFZEHLj2giS5J9GCpkKrb7orMIvKN5GGgrxjvA8wB/U46qXoe/Ap ansible@tower01.tower.demo.redpill-linpro.com
---
# Openstack configuration
openstack_instance:
keypairs:
- name: &key_tower_access ansible_tower_demo_tower_access
public_key_file: files/ssh_keys/ansible_tower_access.pub
- name: &key_node_access ansible_tower_demo_node_access
public_key_file: files/ssh_keys/ansible_client_access.pub
floating_ip:
pool: 'Internet (osl2)'
security_group:
- name: &sgat ansible_tower
description: 'Access to Ansible Tower'
- name: &sgatn ansible_tower_node
description: 'Access to Ansible Tower node'
security_group_role:
- security_group: *sgat
protocol: tcp
port_range_min: 22
port_range_max: 22
- security_group: *sgat
protocol: tcp
port_range_min: 80
port_range_max: 80
- security_group: *sgat
protocol: tcp
port_range_min: 443
port_range_max: 443
- security_group: *sgatn
protocol: tcp
port_range_min: 22
port_range_max: 22
router:
name: tower_demo_router
external_network: 'Internet (osl2)'
os_network:
name: &os_network ansible_tower_network
os_subnet:
name: ansible_tower_subnet
cidr: '192.168.10.0/24'
enable_dhcp: True
network_name: *os_network
os_host:
tower:
- name: tower01.example.com
keyname: *key_tower_access
image: centos7
flavor: lab.gp.medium
security_group: *sgat
userdata: |
#cloud-config
system_info:
default_user:
name: ansible
sudo: ALL=(ALL) NOPASSWD:ALL
packages:
- vim
- tree
- screen
- ansible
- python-pip
package_upgrade: true
final_message: 'The system is finally up after $UPTIME seconds.'
power_state:
deplay: '+5'
mode: reboot
message: 'System rebooting after update.'
timeout: 30
condition: true
nodes:
- name: atn01.example.com
security_group: *sgatn
keyname: *key_node_access
image: centos7
flavor: lab.gp.medium
userdata: |
#cloud-config
system_info:
name: ansible
sudo: ALL=(ALL) NOPASSWD:ALL
- name: atn02.example.com
security_group: *sgatn
keyname: *key_node_access
image: centos7
flavor: lab.gp.medium
userdata: |
#cloud-config
system_info:
name: ansible
sudo: ALL=(ALL) NOPASSWD:ALL
- name: atn03.example.com
security_group: *sgatn
keyname: *key_node_access
image: centos7
flavor: lab.gp.medium
userdata: |
#cloud-config
system_info:
name: ansible
sudo: ALL=(ALL) NOPASSWD:ALL
- name: atn04.example.com
security_group: *sgatn
keyname: *key_node_access
image: centos7
flavor: lab.gp.medium
userdata: |
#cloud-config
system_info:
name: ansible
sudo: ALL=(ALL) NOPASSWD:ALL
# Host configuration
default_packages: vim, tree, screen, ansible, python-pip
ansible_tower_version: '3.5.2-1.el7'
ansible_tower_download_link: "https://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-{{ ansible_tower_version }}.tar.gz"
......
......@@ -4,31 +4,122 @@
- hosts: all
become: no
gather_facts: no
vars:
os_auth: "{{ openstack_instance.os_auth }}"
os_host_network: "{{ openstack_instance.network.network_name }}"
tasks:
- name: RUN ALL COMMANDS AGAINST LOCALHOST
- name: RUN THIS ON LOCALHOST
block:
- name: "CREATE MACHINE IN OPENSTACK [ {{ os_host_name }} ]"
- name: MANAGE KEYPAIRS
os_keypair:
auth: "{{ os_auth }}"
state: present
name: "{{ item.name }}"
public_key_file: "{{ item.public_key_file }}"
loop: "{{ openstack_instance.keypairs }}"
- name: MANAGE TOWER NETWORK
os_network:
state: present
auth: "{{ os_auth }}"
name: "{{ openstack_instance.os_network.name }}"
- name: MANAGE TOWER SUBNET
os_subnet:
state: present
name: "{{ openstack_instance.os_subnet.name }}"
auth: "{{ os_auth }}"
cidr: "{{ openstack_instance.os_subnet.cidr }}"
enable_dhcp: "{{ openstack_instance.os_subnet.enable_dhcp }}"
network_name: "{{ openstack_instance.os_subnet.network_name }}"
- name: MANAGE SECURITY GROUPS
os_security_group:
state: present
description: "{{ sgitem.description | default(omit) }}"
auth: "{{ os_auth }}"
name: "{{ sgitem.name }}"
loop: "{{ openstack_instance.security_group }}"
loop_control:
loop_var: sgitem
- name: MANAGE SECURITY GROUP RULES
os_security_group_rule:
state: present
auth: "{{ os_auth }}"
security_group: "{{ sgritem.security_group }}"
port_range_max: "{{ sgritem.port_range_max | default(omit) }}"
port_range_min: "{{ sgritem.port_range_min | default(omit) }}"
protocol: "{{ sgritem.protocol | default(omit) }}"
loop: "{{ openstack_instance.security_group_role }}"
loop_control:
loop_var: sgritem
- name: MANAGE NETWORK ROUTER
os_router:
state: present
name: "{{ openstack_instance.router.name }}"
auth: "{{ os_auth }}"
network: "{{ openstack_instance.router.external_network }}"
interfaces:
- "{{ openstack_instance.os_subnet.name }}"
admin_state_up: True
- name: 'CREATE TOWER MACHINE(S) IN OPENSTACK'
os_server:
name: "{{ item.name }}"
state: present
auth: "{{ os_auth }}"
name: "{{ item }}"
image: "{{ os_host_image }}"
flavor: "{{ os_host_flavor }}"
security_groups: "{{ os_host_securitygroups | default(omit) }}"
key_name: "{{ os_host_keyname }}"
image: "{{ item.image }}"
flavor: "{{ item.flavor }}"
security_groups: "{{ item.security_group }}"
key_name: "{{ item.keyname }}"
timeout: "{{ os_host_timeout | default(100) }}"
auto_ip: False
auto_ip: false
userdata: "{{ item.userdata | default(omit) }}"
nics:
- net-name: "{{ openstack_instance.os_network.name }}"
loop: "{{ openstack_instance.os_host.tower }}"
- name: MANAGE FLOATING IPS
os_floating_ip:
state: present
auth: "{{ os_auth }}"
reuse: yes
network: "{{ openstack_instance.floating_ip.pool }}"
server: "{{ item.name }}"
loop: "{{ openstack_instance.os_host.tower }}"
- name: 'CREATE ANSIBLE TOWER NODES IN OPENSTACK'
os_server:
name: "{{ item.name }}"
state: present
auth: "{{ os_auth }}"
image: "{{ item.image }}"
flavor: "{{ item.flavor }}"
security_groups: "{{ item.security_group }}"
key_name: "{{ item.keyname }}"
timeout: "{{ os_host_timeout | default(100) }}"
auto_ip: false
userdata: |
system_info:
default_user:
name: ansible
sudo: ALL=(ALL) NOPASSWD:ALL
nics:
- net-name: 'rl_conference_demo'
loop: "{{ lookup('list', os_host_name) }}"
when: os_host_name is defined
- net-name: "{{ openstack_instance.os_network.name }}"
loop: "{{ openstack_instance.os_host.nodes }}"
- name: GATHER FACTS
os_server_facts:
auth: "{{ os_auth }}"
server: "{{ item.name }}"
filters:
vm_state: active
loop: "{{ openstack_instance.os_host.tower }}"
- debug:
var: openstack_servers
delegate_to: localhost
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment