Commit e705016f authored by Daniele Santoro's avatar Daniele Santoro
Browse files

Release lab lesson 5

parent 052ac271
......@@ -45,4 +45,5 @@ by us distributing a =Vagrantfile= and a =provisioning script=.
- [[file:e14][Exercise 14 – Run a Service with Docker]]
- [[file:e15][Exercise 15 - Run a custom Service with Docker]]
- [[file:e16][Exercise 16 - Run a custom Docker Service with persistency]]
* Lab05_20220422
- [[file:e17][Exercise 17 - Create an OpenStack instance based on DevStack]]
......@@ -22,7 +22,6 @@
** Build the image
#+BEGIN_SRC sh
cd e4
docker build -t hub.docker.com/myfiglet-${USER: -3} .
#+END_SRC
** List all images
......
* Exercise 17 – Create an OpenStack instance based on DevStack
- Time :: 40 minutes
- 40 minutes: /Try by yourself/
- Description :: Install OpenStack using DevStack on a dedicated virtual machine.
* Solutions and Instructions
** References
- [[https://docs.openstack.org/devstack/latest/]]
- [[https://opendev.org/openstack/devstack]]
** Provision the OpenStack VM using Vagrant
The specs for this Virtual Machine are quite huge: =6GB of memory= and =4 vCPU= so please ensure to have enough free resoruces on your host.
#+begin_src sh
vagrant up
#+end_src
** Prepare DevStack environement
Download the DevStack release
#+begin_src sh
vagrant ssh
cd /vagrant
chmod a+x devstack-init.sh
sudo -u stack ./devstack-init.sh
#+end_src
Customise DevStack environment
#+begin_src sh
sudo -s -u stack
cd
cp /vagrant/localrc.conf devstack/local.conf
#+end_src
Customise =local.conf= with VM ip, first get the IP
#+begin_src sh
hostname -I | awk '{print $1}'
#+end_src
Edit =devstack/local.conf= and add this line at the top
#+begin_src sh
HOST_IP=THE_IP_FROM_STEP_ABOVE
#+end_src
You should get something liek this:
#+begin_example
...
USE_PYTHON3=True
LOGFILE=$DEST/logs/stack.sh.log
HOST_IP=10.0.2.15
ADMIN_PASSWORD=password
DATABASE_PASSWORD=password
...
#+end_example
** Install the DevStack environement
This step could last ~40 minutes
#+begin_src sh
cd devstack
./stack.sh
#+end_src
At the end of the process you should get a message like this:
#+begin_example
=========================
DevStack Component Timing
(times are in seconds)
=========================
wait_for_service 19
pip_install 374
apt-get 272
run_process 31
dbsync 41
git_timed 545
apt-get-update 3
test_with_retry 3
osc 238
-------------------------
Unaccounted time 421
=========================
Total runtime 1947
This is your host IP address: 10.0.2.15
This is your host IPv6 address: ::1
Horizon is now available at http://10.0.2.15/dashboard
Keystone is serving at http://10.0.2.15/identity/
The default users are: admin and demo
The password: password
#+end_example
Setup you SSH-based socks proxy and access and access with a browser to =http://10.0.2.15/dashboardg=
# -*- mode: ruby -*-
# vi: set ft=ruby :
ANSIBLE_LOGLEVEL = ENV['ANSIBLE_LOGLEVEL'] || "v"
ANSIBLE_PLAYBOOK = ENV['ANSIBLE_PLAYBOOK'] || "provision.yml"
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "ubuntu/focal64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# Customize the amount of memory on the VM:
vb.memory = "6144"
vb.cpus = "4"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# Shared configuration
config.vm.provision :ansible do |ansible|
ansible.verbose = ANSIBLE_LOGLEVEL
ansible.playbook = ANSIBLE_PLAYBOOK
end
end
#cloud-config
# https://docs.openstack.org/devstack/latest/guides/single-vm.html
# https://cloudinit.readthedocs.io/en/latest/topics/modules.html?highlight=reboot#package-update-upgrade-install
output: {all: '| tee -a /var/log/cloud-init-output-script.log'}
packages:
- dstat
- git
- htop
- linux-image-extra-virtual
- rsync
- tmux
- screen
- vim
- wget
- jq
- emacs-nox
- snapd
package_update: true
package_upgrade: true
package_reboot_if_required: true
users:
- default
- name: stack
lock_passwd: true
sudo: ["ALL=(ALL) NOPASSWD:ALL\nDefaults:stack !requiretty"]
shell: /bin/bash
write_files:
- path: "/home/stack/local.conf"
permissions: "0755"
encoding: b64
content: "{{lookup('file', 'localrc.conf')|b64encode }}"
- path: "/home/stack/devstack-init.sh"
permissions: "0755"
content: |
#!/bin/sh
set -x
set -e
OS_VERSION="stable/victoria"
sudo chown stack:stack /home/stack
cd /home/stack
git clone https://opendev.org/openstack-dev/devstack -b "${OS_VERSION}"
cd devstack
echo enable_plugin swift https://opendev.org/openstack/swift "${OS_VERSION}" >> local.conf
runcmd:
- sudo -u stack -i ./devstack-init.sh
- sudo -u stack -i mv local.conf devstack
- sudo -u stack -i sh -c 'cd devstack && ./stack.sh'
#!/bin/sh
set -x
set -e
OS_VERSION="stable/victoria"
sudo chown stack:stack /home/stack
cd /home/stack
git clone https://opendev.org/openstack-dev/devstack -b "${OS_VERSION}"
cd devstack
echo enable_plugin swift https://opendev.org/openstack/swift "${OS_VERSION}" >> local.conf
[[local|localrc]]
USE_PYTHON3=True
LOGFILE=$DEST/logs/stack.sh.log
ADMIN_PASSWORD=password
DATABASE_PASSWORD=password
RABBIT_PASSWORD=password
SERVICE_PASSWORD=password
SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
SWIFT_REPLICAS=1
SWIFT_DATA_DIR=$DEST/data
enable_service s-proxy s-object s-container s-account
enable_plugin swift https://opendev.org/openstack/swift stable/victoria
LOGDAYS=365
LOG_COLOR=False
# # Install the Magnum service (K8s cluster manager) and its GUI
# # Magnum requires the Heat service (cloud application orchestration)
# enable_plugin heat https://opendev.org/openstack/heat stable/victoria
# enable_plugin heat-dashboard https://opendev.org/openstack/heat-dashboard stable/victoria
# enable_plugin magnum https://opendev.org/openstack/magnum stable/victoria
# enable_plugin magnum-ui https://opendev.org/openstack/magnum-ui stable/victoria
# # Install the Octavia service (load balancer) and its GUI
# # Barbican (service for storing secrets) is probably optional.
# enable_plugin barbican https://opendev.org/openstack/barbican stable/victoria
# # enable_plugin barbican_ui https://opendev.org/openstack/barbican-ui master
# # enable_service rabbit mysql key
# enable_plugin octavia https://opendev.org/openstack/octavia stable/victoria
# enable_plugin octavia-dashboard https://opendev.org/openstack/octavia-dashboard stable/victoria
# # ENABLED_SERVICES+=,octavia,o-api,o-cw,o-hk,o-hm,o-da
# enable_service octavia o-api o-cw o-hm o-hk o-da
# enable_plugin ceilometer https://opendev.org/openstack/ceilometer stable/victoria
# enable_plugin aodh https://opendev.org/openstack/aodh stable/victoria
# # Enable Cinder-Backup
# enable_service c-bak
# /var/opt/stack/openstack_dashboard/local/local_settings.d/_123_cinder_backup_settings.py
# OPENSTACK_CINDER_FEATURES = {
# 'enable_backup': True,
# }
# Tempest
# enable_service tempest
# NEOF
---
# File: provision.yml - Install devstack
- hosts: all
become: true
tasks:
- name: Upgrade the OS (apt-get dist-upgrade)
apt:
upgrade: dist
- name: Run the equivalent of "apt-get update" as a separate step
apt:
update_cache: yes
- name: Install packages
apt:
pkg:
- dstat
- git
- htop
- rsync
- tmux
- screen
- vim
- wget
- jq
- snapd
- name: Add the user 'stack'
user:
name: stack
shell: /bin/bash
home: /home/stack
groups: admin, sudo
append: yes
- name: Allow 'stack' to have passwordless sudo
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%stack'
line: '%stack ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
\ No newline at end of file
Supports Markdown
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