#cloud-config
hostname: teste
fqdn: teste.meudominio.br
ssh_pwauth:
False
password: cloudsenha
chpasswd: {expire: False}
package_upgrade: true
packages:
-
httpd
http://cloudinit.readthedocs.io/en/latest/topics/examples.html
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cloudinit-update-vm
Outras informações: https://www.ic.unicamp.br/~william/howto/cloud-init.html
#!/bin/bash
KEY="SSH
Key Name"
BOOTIMG="IMAGE
UUID"
ZONE="NL1"
FLAVOR="Standard
1"
source
~/computerc
for
RUN in {1..20}; do
echo
"Creating VM ${RUN}""
VMUUID=$(nova
boot \
--image
"${BOOTIMG}" \
--flavor
"${FLAVOR}" \
--availability-zone
"${ZONE}" \
--nic
net-id=00000000-0000-0000-0000-000000000000 \
--key-name
"${KEY}" \
--user-data
user_data.file \
"VPS-${RUN}-${ZONE}"
| awk '/id/ {print $4}' | head -n 1);
until
[[ "$(nova show ${VMUUID} | awk '/status/ {print $4}')" ==
"ACTIVE" ]]; do
:
done
echo
"VM ${RUN} (${VMUUID}) is active."
done
Apos instalado o vagrant
$
vagrant
plugin install vagrant-openstack-provider
$ vim $HOME/Vagrantfile
#
Inicio
::
Vagrantfile ::
require
'vagrant-openstack-provider'
Vagrant.configure("2")
do |config|
config.ssh.username
= 'ubuntu'
config.vm.provider
:openstack do |os|
os.server_name
= 'openwhisk'
os.identity_api_version
= '3'
os.openstack_auth_url
= 'http://cloud.ic.unicamp.br:5000/v3'
os.project_name
= 'OPENWHISK'
os.domain_name
= 'default'
os.region
= 'RegionOne'
os.username
= 'william'
os.password
= 'suasenha123'
os.tenant_name
= 'OPENWHISK'
os.flavor
= 'm1.small.cpu-shared'
os.image
= 'Ubuntu-xenial-server-amd64-16.04-LTS'
os.networks
= 'private'
os.floating_ip_pool
= 'public'
end
end
# Fim :: Vagrantfile ::
$
vagrant up
$
vagrant ssh
Se precisar do debug do Vagrant para Openstack set a variavel a seguir:
$
export
VAGRANT_OPENSTACK_LOG=debug
Outras informações: https://github.com/ggiamarchi/vagrant-openstack-provider
Usando Vagrant com OpenStack
https://blog.scottlowe.org/2015/09/28/using-vagrant-with-openstack/
# glance image-list
# glance image-show 16d19c89-c18c-4f0b-b44d-7d2dd535610
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | bc62ad193b085680952edfa7face0f23 |
| container_format | bare |
| created_at | 2017-12-08T15:36:58Z |
| disk_format | qcow2 |
| id | 16d19c89-c18c-4f0b-b44d-7d2dd535610 |
| min_disk | 0 |
| min_ram | 0 |
| name | WebDev-CentOS7 |
| owner | d231419875196519513741397156ad45 |
| protected | True |
| size | 1361182720 |
| status | active |
| tags | [] |
| updated_at | 2017-12-08T15:49:15Z |
| virtual_size | None |
| visibility | private |
+------------------+--------------------------------------+
# glance image-update --visibility shared 16d19c89-c18c-4f0b-b44d-7d2dd535610
# glance member-create 16d19c89-c18c-4f0b-b44d-7d2dd535610b 752972547896627398451785cda23414
# glance member-list --image-id 16d19c89-c18c-4f0b-b44d-7d2dd535610b
+--------------------------------------+----------------------------------+----------+
| Image ID | Member ID | Status |
+--------------------------------------+----------------------------------+----------+
| 16d19c89-c18c-4f0b-b44d-7d2dd535610b | d231419875196519513741397156ad45 | accepted |
| 16d19c89-c18c-4f0b-b44d-7d2dd535610b | 752972547896627398451785cda23414 | pending |
| 16d19c89-c18c-4f0b-b44d-7d2dd535610b | a987d7a56d78a697da876da8756da5c1 | accepted |
| 16d19c89-c18c-4f0b-b44d-7d2dd535610b | aad897ad87a98d6ad968a87d58a5dad8 | accepted |
| 16d19c89-c18c-4f0b-b44d-7d2dd535610b | 4ad987ad987ad6598ad85ad654ad63a0 | accepted |
+--------------------------------------+----------------------------------+----------+
# glance member-update 16d19c89-c18c-4f0b-b44d-7d2dd535610b 752972547896627398451785cda23414 accepted
$ openstack image set --property hw_disk_bus='ide' image_name_or_id
https://www.youtube.com/watch?v=TsESYPz3uGo
https://cloudblog.switch.ch/2015/09/22/hack-neutron-to-add-more-ip-addresses-to-an-existing-subnet/
## ADMSIS
#LAUNCH_INSTANCE_DEFAULTS = { # 'config_drive': False, # 'enable_scheduler_hints': True # 'disable_image': False, # 'disable_instance_snapshot': False, # 'disable_volume': True, # 'disable_volume_snapshot': False, #}
LAUNCH_INSTANCE_DEFAULTS = { 'config_drive': False, 'create_volume': False, 'disable_image': False, 'disable_instance_snapshot': False, 'disable_volume': True, 'disable_volume_snapshot': True, }
Referencia: https://ask.openstack.org/en/question/106169/disable-create-new-volume-from-horizon/
http://behindtheracks.com/openstack-high-
https://docs.openstack.org/ha-
Associar um determinado IP para um projeto:
openstack floating ip create --floating-ip-address
https://ask.openstack.org/en/question/66918/how-to-delete-volume-with-available-status-and-attached-to/