In lab six, we will apply everything we have learned and use the available Ansible OpenStack modules to accomplish the following tasks:
-
Creation of a private network using
os_network
module -
Creation of a private subnet to associate to the private network using the
os_subnet
module. Use CIDR 192.168.0.1/24 -
Creation of a router to associate with the private network using the
os_router
module -
Create an OpenStack keypair using the public key on the localhost
-
Updating the default security group to allow
icmp
(ping) andssh
access via port 22. -
Creation of an OpenStack instance using the
os_instance
module -
Updating quotas to the OpenStack project
os_quota
Note
|
A public network has already been created for you. |
HINT: Register the value of the private subnet in order to pass the OpenStack subnet ID to the OpenStack router.
When using any of the modules make sure to use the mycloud as the value for the cloud argument. The mycloud is the name of the cloud with the authentication credentials provided within the cloud.yml file located in /etc/openstack.
Assignment: Attempt to create a playbook.yml file that accomplishes all the
task bullets. Ensure to take advantage of the Ansible documentation for clues
on how to complete each task and also via command-line make use of the ansible-doc
command for examples.
Example of using ansible-doc
:
$ ansible-doc os_network
The above command would provide documentation on how to use the OpenStack
os_network
module.
Answer to the following exercise:
--- - name: Lab 6 OpenStack Comprehensive Review hosts: localhost vars: flavor: m1.small key_name: demokp server_name: studentX image: cirros tasks: - name: Create a private network named studentX_private_network using os_network os_network: cloud: mycloud state: present name: studentX_private_network - name: Create a private subnet named studentX_private_subnet using os_subnet with CIDR 192.168.0.0/24 os_subnet: cloud: mycloud state: present network_name: studentX_private_network name: studentX_private_subnet cidr: 192.168.0.1/24 register: subnet - name: Create a router named studentX_router1. os_router: cloud: mycloud state: present name: studentX_router1 - name: Update default security group to allow ICMP traffic os_security_group_rule: cloud: mycloud state: present security_group: default protocol: icmp remote_ip_prefix: 0.0.0.0/0 - name: Update default security group to allow SSH traffic os_security_group_rule: cloud: mycloud state: present security_group: default protocol: tcp port_range_min: 22 port_range_max: 22 remote_ip_prefix: 0.0.0.0/0 - name: Update project's quota os_quota: cloud: admin name: demo cores: 4 instances: 2 - name: Create an OSP Keypair using public key os_keypair: cloud: mycloud state: present name: "{{ key_name }}" public_key_file: "{{ ansible_user_dir }}/.ssh/id_rsa.pub" - name: Launch an OpenStack instance os_server: cloud: mycloud state: present name: "{{ server_name }}" flavor: "{{ flavor }}" image: "{{ image }}" key_name: "{{ key_name }}" security_groups: default network: private_network ...