Last active
November 21, 2016 14:20
-
-
Save odyssey4me/863e84a0f6271712c6d48980cffb958d to your computer and use it in GitHub Desktop.
Test openstack-ansible multi-node using cloud instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure that your cloud account has an ssh key configured | |
# which you are prepared to use on an instance in the cloud. | |
# Create network for inter-host communication: | |
# name: 'internal-net' | |
# CIDR: '192.168.3.0/24' | |
# Create instances for your environment (make sure that the extra network is selected): | |
# infra1 | |
# g1-8 flavor (8CPU, 8RAM, 160GB HDD) | |
# Ubuntu 14.04 LTS PVHVM image | |
# compute1 | |
# g1-8 flavor (8CPU, 8RAM, 160GB HDD) | |
# Ubuntu 14.04 LTS PVHVM image | |
# storage1 | |
# g1-8 flavor (8CPU, 8RAM, 160GB HDD) | |
# Ubuntu 14.04 LTS PVHVM image | |
# SSH to the public IP address for infra1 | |
### | |
### Prepare infra1 as the deployment host | |
### | |
# This section matches to this part of the docs: | |
# http://docs.openstack.org/developer/openstack-ansible/install-guide/deploymenthost.html | |
# There are some extra bits here due to running this test in cloud instances. | |
# Install git and some other bits | |
apt-get update && \ | |
apt-get purge -y nano && \ | |
apt-get install -y git vim tmux fail2ban | |
# Enter a tmux session | |
tmux new | |
# If you lose connection, just ssh back to the | |
# instance and execute the following to reattach | |
# to the same session. | |
# tmux attach | |
# Setup the various variables and git settings to | |
# allow you to download patches from gerrit. | |
git config --global user.email "<your email address>" | |
git config --global user.name "<your name>" | |
git config --global push.default matching | |
git config --global --add gitreview.username "<your gerrit username>" | |
# Set up the ssh keys which will allow you to access | |
# all the instances. | |
mkdir -p ~/.ssh | |
vi ~/.ssh/id_rsa # copy your ssh private key contents into this file | |
vi ~/.ssh/id_rsa.pub # copy your ssh public key contents into this file | |
chmod -R 700 ~/.ssh | |
# Prepare a bootstrapping inventory for the instances. | |
# Make sure to replace <public ip address> with each instance IP address. | |
# Put the file (located near the bottom of this gist) into the root home directory. | |
# file name: '~/inventory.ini' | |
# Create a playbook to execute the bootstrap-host role against | |
# the instances in order to prepare their networking. | |
# Put the file (located near the bottom of this gist) into the root home directory. | |
# file name: '~/bootstrap-hosts.yml' | |
# Clone the openstack-ansible repository. | |
git clone https://github.com/openstack/openstack-ansible.git /opt/openstack-ansible | |
cd /opt/openstack-ansible | |
# Set the role clone method to use git. (optional step) | |
# This is to allow patches to be applied if need be. | |
export ANSIBLE_ROLE_FETCH_MODE="git-clone" | |
# Setup ansible for openstack-ansible usage | |
./scripts/bootstrap-ansible.sh | |
### | |
### Prepare the target hosts | |
### | |
# This section matches to this part of the docs: | |
# http://docs.openstack.org/developer/openstack-ansible/install-guide/targethosts-prepare.html | |
# Execute the bootstrap playbook against your environment. | |
# This takes care of all host bootstrapping, so you don't have to. :) | |
cd tests | |
ansible-playbook -i ~/inventory.ini ~/bootstrap-hosts.yml | |
### | |
### Prepare the OpenStack-Ansible configuration | |
### | |
# You can now continue through the documentation: | |
# http://docs.openstack.org/developer/openstack-ansible/install-guide/configure.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
gather_facts: yes | |
roles: | |
- role: "bootstrap-host" | |
bootstrap_host_aio_config: no | |
encapsulation_interface: eth2 | |
node_id: "{{ hostvars[inventory_hostname]['ansible_eth2']['ipv4']['address'].split('.')[-1] }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[all] | |
infra1 ansible_ssh_host=<public ip address> ansible_ssh_user=root | |
compute1 ansible_ssh_host=<public ip address> ansible_ssh_user=root | |
storage1 ansible_ssh_host=<public ip address> ansible_ssh_user=root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment