Skip to content

Commit

Permalink
adding a playbook
Browse files Browse the repository at this point in the history
Adding a ReadMe file for provisioning OpenStack

made changes to the files

adding quotes

changed the readme extension

deleted extra spaces

changed README name

adding updated playbook and README

made changes to README and playbook

Edited Readme
  • Loading branch information
Likhitha Eda committed Aug 3, 2020
1 parent 6e60b93 commit 24e4f34
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
18 changes: 18 additions & 0 deletions playbooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Automate Provisioning OpenStack Instance

- The Ansible playbook will automate the creation of an openstack instance.
- The playbook contains the neccessary parameters to create the instance.
- The parameters include: image, key_name, flavor, network, and security_groups
- The parameters image, flavor, network, and security groups must be passed in the command line as extra-vars when running the playbook.

### Steps to Create the OS Instance
1. Run the following commands to set up the OpenStack credentials:
**export OS_AUTH_URL= < url-to-openstack-identity > #you can get this url from OS VM
export OS_PROJECT_NAME= < project-name >
export OS_USER_DOMAIN_NAME= < domain-name > *# (optional)*
export OS_PROJECT_DOMAIN_ID= < domain-ID > *# (optional)*
export OS_USERNAME= < user-name >
export OS_PASSWORD= < password > # *(optional)***

2. Run the playbook with the following command and provide the parameters as extra-vars:
**ansible-playbook -vv -i "localhost," --connection=local provision_openstack_instance.yml -e "vm_name=< give a name for the VM > image=< image name > flavor=< flavor name > network=< network name > sec_groups= < security groups name >"**
27 changes: 27 additions & 0 deletions playbooks/provision_openstack_instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: "Provision Open Stack Instance"
hosts: '{{ hosts | default("all") }}'
become: '{{ become | default("no") }}'
gather_facts: '{{ gather_facts | default("no") }}'
tasks:

- name: "provision a key pair"
os_keypair:
state: present
name: ansible_key
register: keypair_output

- name: "copy the keypair_output to a file"
copy:
content: keypair_output["private_key"]
dest: "~/.ssh/keypair_output.pem"

- name: "Create a new OpenShift instance on Virtual Machine"
os_server:
state: present
name: "{{ vm_name }}"
image: "{{ image }}"
key_name: ansible_key
flavor: "{{ flavor }}"
network: "{{ network }}"
security_groups: "{{ sec_groups }}"

0 comments on commit 24e4f34

Please sign in to comment.