Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #16 from eumel8/dev
Browse files Browse the repository at this point in the history
Dev20180420
  • Loading branch information
eumel8 authored Apr 20, 2018
2 parents 8e96416 + 584454e commit 815c55c
Show file tree
Hide file tree
Showing 67 changed files with 440 additions and 548 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ ansible_otc.egg-info/
doc/build/
playbooks/test.*
playbooks/roles.yml
AUTHORS
ChangeLog
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ python:
# https://docs.travis-ci.com/user/common-build-problems/
env:
- ANSIBLE_VERSION=latest
- ANSIBLE_VERSION=2.2.2.0
- ANSIBLE_VERSION=2.3.0.0
- ANSIBLE_VERSION=2.4.0.0
- ANSIBLE_VERSION=2.5.0b2
- ANSIBLE_VERSION=2.4.3.0
- ANSIBLE_VERSION=2.5.0

branches:
only:
- master
- dev

before_install:
- sudo apt-get update -qq
# before_install:
# - sudo apt-get update -qq

install:
# Install Ansible.
Expand All @@ -31,7 +29,7 @@ install:

script:
# Check the role/playbook's syntax.
- ansible-lint .
- find roles/ -name "*.yml" | xargs ansible-lint

# Run the role/playbook with ansible-playbook.
- tests/tests.sh
- tests/tests.sh
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ For local build use:
pip install -r requirements.txt
```


Presentations
=============

* https://www.slideshare.net/FrankKloeker/ansible-otc


Contributing
------------
Very welcome. We are in a very early state of automated platform deployment
Expand Down
37 changes: 37 additions & 0 deletions doc/source/ara.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ARA - Ansible Run Analysis
==========================

ARA records Ansible playbook runs and makes the recorded data
available and intuitive for users and systems. It's described
on `ARA ReadTheDocs <http://ara.readthedocs.io/en/latest/>`__.

ARA doesn't run your playbooks for you: it integrates with Ansible
as a callback plugin wherever it is. In ``playbooks/ara.sh`` is a
workflow described as an example::

export ANSIBLE_CALLBACK_PLUGINS=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")/plugins/callbacks
export ANSIBLE_ACTION_PLUGINS=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")/plugins/actions
export ANSIBLE_LIBRARY=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")/plugins/modules

ansible-playbook roles.yml
ara generate html ./html

The ``html`` directory should be accessable within a webbrowser to fits
the best view.
It's also possible to handle this in CI/CD environments,
like .gitlab-ci.yml::

araweb:
stage: araweb
script:
- tar cfz ara_html.tgz tests/html
tags:
- araweb
artifacts:
paths:
- ara_html*.tgz
expire_in: 1 week


See also on `Github <https://github.com/openstack/ara>`__ and this
`OpenStack SuperUser article <http://superuser.openstack.org/articles/scaling-ara-ansible/>`__.
4 changes: 4 additions & 0 deletions doc/source/authors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Authors
=======

.. literalinclude:: ../../AUTHORS
2 changes: 1 addition & 1 deletion doc/source/connect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Alternate way::
apt-get -y install curl git python-openstackclient python-pip python-jmespath python-netaddr libs3-2 jq
pip install pip -U
pip install python-otcclient
pip install ansible==2.2.0.0
pip install ansible==2.5.0.0

Follow instruction as normal user. You need always username, password, domain data.

Expand Down
1 change: 1 addition & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Welcome to Ansible-OTC documentation!
workshop
buildservice
dns
ara
roles
changelog
authors
Expand Down
4 changes: 2 additions & 2 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Installrequirements
* curl
* openssl
* base64
* ansible==2.2.0.0
* ansible==2.5.0.0
* python-jmespath
* python-netaddr

Expand All @@ -15,7 +15,7 @@ Installrequirements
apt-get update
apt-cache policy ansible
apt-get install curl python-pip python-jmespath python-netaddr
pip install ansible==2.2.0.0
pip install ansible==2.5.0.0
*OpenSuSE 13.2:*::
Expand Down
19 changes: 10 additions & 9 deletions doc/source/roles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ Variables:
Functions:
==========

.. include:: ../../roles/os-client-config/README.rst
.. include:: ../../roles/otc_auth/README.rst
.. include:: ../../roles/otc_ims/README.rst
.. include:: ../../roles/otc_vpc/README.rst
.. include:: ../../roles/otc_subnet/README.rst
.. include:: ../../roles/otc_secgroup/README.rst
.. include:: ../../roles/otc_keypair/README.rst
.. include:: ../../roles/otc_eip/README.rst
.. include:: ../../roles/otc_dns/README.rst
.. include:: ../../roles/otc_ecs/README.rst
.. include:: ../../roles/otc_eip/README.rst
.. include:: ../../roles/otc_elb/README.rst
.. include:: ../../roles/otc_evs/README.rst
.. include:: ../../roles/otc_dns/README.rst
.. include:: ../../roles/otc_obs/README.rst
.. include:: ../../roles/otc_ims/README.rst
.. include:: ../../roles/otc_job/README.rst
.. include:: ../../roles/otc_elb/README.rst
.. include:: ../../roles/otc_keypair/README.rst
.. include:: ../../roles/otc_obs/README.rst
.. include:: ../../roles/otc_rds/README.rst
.. include:: ../../roles/otc_secgroup/README.rst
.. include:: ../../roles/otc_subnet/README.rst
.. include:: ../../roles/otc_vpc/README.rst
8 changes: 8 additions & 0 deletions playbooks/ara.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

export ANSIBLE_CALLBACK_PLUGINS=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")/plugins/callbacks
export ANSIBLE_ACTION_PLUGINS=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")/plugins/actions
export ANSIBLE_LIBRARY=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")/plugins/modules

ansible-playbook roles.yml
ara generate html ./html
4 changes: 2 additions & 2 deletions playbooks/tenant_ini.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
subnet_dhcp_enable: "{{ lookup('ini', 'subnet_dhcp_enable section={{ ecs_name }} file={{ tenant_ini }}') | default(lookup('ini', 'subnet_dhcp_enable section=DEFAULT file={{ tenant_ini }}') ) }}"
subnet_primary_dns: "{{ lookup('ini', 'subnet_primary_dns section={{ ecs_name }} file={{ tenant_ini }}') | default(lookup('ini', 'subnet_primary_dns section=DEFAULT file={{ tenant_ini }}') ) }}"
subnet_secondary_dns: "{{ lookup('ini', 'subnet_secondary_dns section={{ ecs_name }} file={{ tenant_ini }}') | default(lookup('ini', 'subnet_secondary_dns section=DEFAULT file={{ tenant_ini }}') ) }}"
vpc_name: "{{ lookup('ini', 'vpc_name section={{ ecs_name }} file={{ tenant_ini }}') | default(lookup('ini', 'vpc_name section=DEFAULT file={{ tenant_ini }}') ) }}"
vpc_net: "{{ lookup('ini', 'vpc_net section={{ ecs_name }} file={{ tenant_ini }}') | default(lookup('ini', 'vpc_net section=DEFAULT file={{ tenant_ini }}') ) }}"
vpc_name: "{{ lookup('ini', 'vpc_name section={{ ecs_name }} file={{ tenant_ini }}') }}"
vpc_net: "{{ lookup('ini', 'vpc_net section={{ ecs_name }} file={{ tenant_ini }}') }}"
# EVS vars
evs_availability_zone: "{{ lookup('ini', 'evs_availability_zone section={{ evs_name }} file={{ tenant_ini }}') | default(lookup('ini', 'evs_availability_zone section=DEFAULT file={{ tenant_ini }}') ) }}"
evs_volume_type: "{{ lookup('ini', 'evs_volume_type section={{ evs_name }} file={{ tenant_ini }}') | default(lookup('ini', 'evs_volume_type section=DEFAULT file={{ tenant_ini }}') ) }}"
Expand Down
4 changes: 2 additions & 2 deletions playbooks/tenant_json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
tenant_cf: "{{ lookup('file', tenant_json) | from_json }}"
image_name: "{{ tenant_cf['vms'][ecs_name]['image_name'] | default(tenant_cf['default']['image_name']) }}"
availability_zone: "{{ tenant_cf['vms'][ecs_name]['availability_zone'] | default(tenant_cf['default']['availability_zone']) }}"
vpc_name: "{{ tenant_cf['vms'][ecs_name]['vpc_name'] | default(tenant_cf['default']['vpc_name']) }}"
vpc_net: "{{ tenant_cf['vms'][ecs_name]['vpc_net'] | default(tenant_cf['default']['vpc_net']) }}"
vpc_name: "{{ tenant_cf['vms'][ecs_name]['vpc_name'] }}"
vpc_net: "{{ tenant_cf['vms'][ecs_name]['vpc_net'] }}"
subnet_name: "{{ tenant_cf['vms'][ecs_name]['subnet_name'] | default(tenant_cf['default']['subnet_name']) }}"
subnet_net: "{{ tenant_cf['vms'][ecs_name]['subnet_net'] | default(tenant_cf['default']['subnet_net']) }}"
subnet_gateway: "{{ tenant_cf['vms'][ecs_name]['subnet_gateway'] | default(tenant_cf['default']['subnet_gateway']) }}"
Expand Down
4 changes: 2 additions & 2 deletions playbooks/tenant_yml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# VPC,Subnet,Secgroup,ECS,EIP
image_name: "{{ vms[ecs_name].image_name | default(default.image_name) }}"
availability_zone: "{{ vms[ecs_name].availability_zone | default(default.availability_zone) }}"
vpc_name: "{{ vms[ecs_name].vpc_name | default(default.vpc_name) }}"
vpc_net: "{{ vms[ecs_name].vpc_net | default(default.vpc_net) }}"
vpc_name: "{{ vms[ecs_name].vpc_name }}"
vpc_net: "{{ vms[ecs_name].vpc_net }}"
subnet_name: "{{ vms[ecs_name].subnet_name | default(default.subnet_name) }}"
subnet_net: "{{ vms[ecs_name].subnet_net | default(default.subnet_net) }}"
subnet_gateway: "{{ vms[ecs_name].subnet_gateway | default(default.subnet_gateway) }}"
Expand Down
4 changes: 4 additions & 0 deletions playbooks/vars/dns.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
default:
vpc_name : "ansible-vpc01",
zone_email: "[email protected]",
zone_ttl: 86400
dnszones:
ansible.internal.corp:
zone_description: "Core Zone internal services"
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

pbr>=2.0 # Apache-2.0
sphinx>=1.6.2 # BSD
ansible==2.3.0.0
ansible==2.5.0.0
jmespath
# Ara for Web reports
ara
# OpenStack CLI for Tests
python-openstackclient==3.14.0
46 changes: 46 additions & 0 deletions roles/os-client-config/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
os-client-config
================

OTC role for generate os-clientconfig

Variables:
^^^^^^^^^^

+-------------------------+---------------------------------------------+
| Name | Description |
+=========================+=============================================+
| occ_profile_name | cloud profile name, e.g. otc |
+-------------------------+---------------------------------------------+
| occ_auth_url | IAM auth url (version 3 is default) |
+-------------------------+---------------------------------------------+
| occ_region_name | cloud region name |
+-------------------------+---------------------------------------------+
| occ_username | cloud username |
+-------------------------+---------------------------------------------+
| occ_password | cloud password |
+-------------------------+---------------------------------------------+
| occ_project_name | cloud project name, e.g. eu-de |
+-------------------------+---------------------------------------------+
| occ_project_domain_name | cloud project domain name, e.g. Default |
+-------------------------+---------------------------------------------+
| occ_user_domain_name | cloud user domain, e.g. OTC-eu-de-0012345 |
+-------------------------+---------------------------------------------+

Functions:
^^^^^^^^^^

Create::

ansible-playbook os-client-config.yml

Read::

n/a

Update::

n/a

Delete::

n/a
1 change: 1 addition & 0 deletions roles/os-client-config/templates/cloud.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ clouds:
project_name: {{ occ_project_name }}
project_domain_name: {{ occ_project_domain_name }}
user_domain_name: {{ occ_user_domain_name }}
identity_api_version: "3"
region_name: {{ occ_region_name }}
17 changes: 9 additions & 8 deletions roles/otc_dns/tasks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
register: zone
when: zone_name is defined

- debug:
msg: "{{ zone }}"

- pause:
- name: Pause while creating zone
pause:
minutes: 1

- name: Lookup zone_id
include: lookup.yml

- name: Create zonerecords
include: zonerecord_create.yml
with_items:
- "{{ zone_records }}"
loop_control:
loop_var: zone_record
# with_items:
# - "{{ zone_records }}"
# loop_control:
# loop_var: zone_record
3 changes: 0 additions & 3 deletions roles/otc_dns/tasks/deletegrouploop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,3 @@
Content-Type: "application/json"
X-Auth-Token: "{{ token['x_subject_token'] }}"
register: secgroup

- debug:
msg: "{{ secgroup }}"
2 changes: 1 addition & 1 deletion roles/otc_dns/tasks/list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
zonelist: "{{ zonelist_public.json.zones }} + {{ zonelist_private.json.zones }}"

- name: List zones
debug:
debug:
msg: "{{ zonelist }}"
when: zonelist is defined
9 changes: 0 additions & 9 deletions roles/otc_dns/tasks/lookup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,9 @@
zonelist_result: "{{ zonelist_public.json.zones }} + {{ zonelist_private.json.zones }}"
when: zone_name is defined

- name: Debug zone_name
debug:
msg: "{{ zone_name }}"

- name: Set fact zone_id for dns if zone_name is defined
vars:
zonenamedot: "{{ zone_name }}."
set_fact:
zone_id: "{{ zonelist_result|json_query(\"[?name=='\" + zonenamedot + \"'].id|[0]\") }}"
when: zone_name is defined

- name: Debug zone_id
debug:
msg: "{{ zone_id }}"
when: zone_id is defined
65 changes: 3 additions & 62 deletions roles/otc_dns/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,3 @@
- name: Get Zone list
include: list.yml
when:
- localaction is defined and localaction == "list"
tags:
- zonelist

- name: Get PTR list
include: ptr_list.yml
when:
- localaction is defined and localaction == "ptrlist"
tags:
- ptrlist

- name: Transfer Zone to OTC
include: transfer.yml
when:
- localaction is defined and localaction == "transfer"
tags:
- transfer

- name: Get Zone detail
include: show.yml
when:
- localaction is defined and localaction == "show"
tags:
- zoneshow

- name: Create Zone
include: create.yml
when:
- localaction is defined and localaction == "create"
tags:
- zonecreate

- name: Create PTR
include: ptr_create.yml
when:
- localaction is defined and localaction == "ptrcreate"
tags:
- ptrcreate

- name: Create Zonerecords
include: zonerecord_create.yml
when:
- localaction is defined and localaction == "zonerecordcreate"
tags:
- zonerecordscreate

- name: Delete Zone
include: delete.yml
when:
- localaction is defined and localaction == "delete"
tags:
- zonedelete

- name: Delete PTR
include: ptr_delete.yml
when:
- localaction is defined and localaction == "ptrdelete"
tags:
- ptrdelete
- name: action {{ localaction }}
include: "{{ localaction }}.yml"
when: localaction is defined
Loading

0 comments on commit 815c55c

Please sign in to comment.