test some newcloud things
Signed-off-by: Rick Elrod <relrod@redhat.com>
This commit is contained in:
parent
4aa3d024da
commit
a6eb94929a
2 changed files with 133 additions and 0 deletions
81
playbooks/transient_newcloud_instance.yml
Normal file
81
playbooks/transient_newcloud_instance.yml
Normal file
|
@ -0,0 +1,81 @@
|
|||
#
|
||||
# setup a transient instance in the Fedora infrastructure private cloud
|
||||
#
|
||||
# This playbook is used to spin up a transient instance for someone to test something.
|
||||
# In particular transient instances will all be terminated at least by the next
|
||||
# maint window for the cloud, but ideally people will terminate instances they
|
||||
# are done using.
|
||||
#
|
||||
# If you have an application or longer term item that should always be around
|
||||
# please use the persistent playbook instead.
|
||||
#
|
||||
# You MUST pass a name to it, ie: -e 'name=somethingdescriptive'
|
||||
# You can optionally override defaults by passing any of the following:
|
||||
# image=imagename (default is centos70_x86_64)
|
||||
# instance_type=some instance type (default is m1.small)
|
||||
# root_auth_users='user1 user2 user3' (default is sysadmin-main group)
|
||||
#
|
||||
# Note: if you run this playbook with the same name= multiple times
|
||||
# openstack is smart enough to just return the current ip of that instance
|
||||
# and go on. This way you can re-run if you want to reconfigure it without
|
||||
# reprovisioning it.
|
||||
#
|
||||
# Example command:
|
||||
# transient_cloud_instance.yml --extra-vars="name='foo' image='Fedora-Cloud-Base-20141203-21.x86_64'"
|
||||
#
|
||||
|
||||
- name: check/create instance
|
||||
hosts: batcave01.phx2.fedoraproject.org
|
||||
user: root
|
||||
gather_facts: False
|
||||
|
||||
vars_files:
|
||||
- /srv/web/infra/ansible/vars/global.yml
|
||||
- /srv/private/ansible/vars.yml
|
||||
- /srv/web/infra/ansible/vars/fedora-cloud.yml
|
||||
- /srv/private/ansible/files/openstack/passwords.yml
|
||||
vars:
|
||||
image: "{{ centos70_x86_64 }}"
|
||||
instance_type: m1.small
|
||||
|
||||
tasks:
|
||||
- name: fail when name is not provided
|
||||
fail: msg="Please specify the name of the instance"
|
||||
when: name is not defined
|
||||
|
||||
- import_tasks: "{{ tasks_path }}/transient_newcloud.yml"
|
||||
|
||||
- name: gather facts
|
||||
setup:
|
||||
check_mode: no
|
||||
ignore_errors: True
|
||||
register: facts
|
||||
|
||||
- name: install python2 and dnf stuff
|
||||
raw: dnf -y install python-dnf libselinux-python
|
||||
when: facts is failed
|
||||
|
||||
- name: provision instance
|
||||
hosts: tmp_just_created
|
||||
gather_facts: True
|
||||
environment:
|
||||
ANSIBLE_HOST_KEY_CHECKING: False
|
||||
|
||||
vars_files:
|
||||
- /srv/web/infra/ansible/vars/global.yml
|
||||
- "/srv/private/ansible/vars.yml"
|
||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||
|
||||
tasks:
|
||||
- name: install cloud-utils (yum)
|
||||
package: name=cloud-utils state=present
|
||||
when: ansible_distribution_major_version|int < 22
|
||||
|
||||
- name: install cloud-utils (dnf)
|
||||
command: dnf install -y cloud-utils
|
||||
when: ansible_distribution_major_version|int > 21 and ansible_cmdline.ostree is not defined
|
||||
|
||||
- import_tasks: "{{ tasks_path }}/cloud_setup_basic.yml"
|
||||
|
||||
handlers:
|
||||
- import_tasks: "{{ handlers_path }}/restart_services.yml"
|
52
tasks/transient_newcloud.yml
Normal file
52
tasks/transient_newcloud.yml
Normal file
|
@ -0,0 +1,52 @@
|
|||
- name: spin UP VM using os_server
|
||||
delegate_to: undercloud01.cloud.fedoraproject.org
|
||||
os_server:
|
||||
state: present
|
||||
security_groups: default
|
||||
nics:
|
||||
- net-id: d18c60b1-bba2-416f-87c3-a4416191bd7c
|
||||
name: "{{ name }}"
|
||||
auth:
|
||||
auth_url: http://172.23.1.52:5000/v2.0
|
||||
username: "admin"
|
||||
password: "{{newcloud_os_admin_pw}}"
|
||||
login_tenant_name: relrod-super-cool-test-project
|
||||
image: fedora-28-cloud-test
|
||||
flavor: test.flavor.blah
|
||||
key_name: fedora-admin-20130801
|
||||
auto_floating_ip: true
|
||||
userdata: "#cloud-config\ndisable_root: 0"
|
||||
register: nova_result
|
||||
|
||||
- name: add it to the special group
|
||||
local_action: add_host hostname="{{ nova_result.public_ip }}" groupname=tmp_just_created
|
||||
|
||||
#- name: mail off about where it is
|
||||
# local_action: mail
|
||||
# to=sysadmin-main-members@fedoraproject.org
|
||||
# from=ansible-create@fedoraproject.org
|
||||
# subject="{{ nova_result.public_ip }}"
|
||||
# body="transient cloud instance created on {{ nova_result.public_ip }}
|
||||
# name = {{ name }}
|
||||
# root_auth_users = {{ root_auth_users }}
|
||||
# image = {{ image }}"
|
||||
|
||||
- name: wait for he host to be hot
|
||||
local_action: wait_for host={{ nova_result.public_ip }} port=22 delay=1 timeout=600
|
||||
|
||||
#- name: gather ssh host key from new instance
|
||||
# local_action: command ssh-keyscan -t rsa {{ nova_result.public_ip }}
|
||||
# ignore_errors: True
|
||||
# register: hostkey
|
||||
|
||||
#- name: add new ssh host key (you still need to add it to official ssh_host_keys later)
|
||||
# local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}" host={{ nova_result.public_ip }} state=present
|
||||
# ignore_errors: True
|
||||
# with_items:
|
||||
# - /root/.ssh/known_hosts
|
||||
# - /etc/ssh/ssh_known_hosts
|
||||
|
||||
# SSH is up and running, however cloud-init still did not deployed ssh keypair
|
||||
# we have to wait some time. 10 sec is usually enough, but not always.
|
||||
- name: waiting for cloud-init
|
||||
pause: seconds=30
|
Loading…
Add table
Add a link
Reference in a new issue