Unverified Commit 37a71f28 authored by Ioannis Tsafaras's avatar Ioannis Tsafaras Committed by Avraam Tsantekidis
Browse files

LAM-40 WIP, fixed hosts.j2 template

parent 453b491f
---
- hosts: masters
- hosts: master
user: root
tasks:
- name: Touch master file
......@@ -19,4 +19,7 @@
tags: touch
- name: Remove slave file
file: path=/root/slave state=absent
tags: rm
\ No newline at end of file
tags: rm
- name: Copy hosts file.
template: src=../roles/common/templates/hosts.j2 dest=/etc/hosts backup=no owner=root group=root mode=0750
---
- hosts: masters
- hosts: master
user: root
tasks:
- name: install screen to master without proxy
......
127.0.0.1 localhost
{% for master in groups["master"] %}
{{ hostvars[master]["internal_ip"] }} {{ master }}
{{ hostvars[master]["internal_ip"] }} {{ master | replace(".vm.okeanos.grnet.gr","") }}
{% endfor %}
{% for slave in groups["slaves"] %}
{{ hostvars[slave]["internal_ip"] }} {{ slave }}
{{ hostvars[slave]["internal_ip"] }} {{ slave | replace(".vm.okeanos.grnet.gr","") }}
{% endfor %}
# The following lines are desirable for IPv6 capable hosts
......
......@@ -16,13 +16,13 @@ class Manager:
if group == "master":
self.master_fqdn = response[u'SNF:fqdn'].split('.')[0]
def create_inventory(self, private_ips):
def create_inventory(self):
"""
Create the inventory using the ansible library objects
:return:
"""
ipdict = {"snf-661243": "192.168.0.2", "snf-661526" : "192.168.0.3", "snf-661527" : "192.168.0.4"}
inventory_groups = []
host_vars = {}
......@@ -69,11 +69,143 @@ class Manager:
if __name__ == "__main__":
inv = test_provisioner_response = \
{"master": [{u'addresses': {}, u'links': [
{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'self'},
{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'bookmark'}],
u'image': {
u'id': u'0e399015-8723-4c78-8198-75bdf693cdde',
u'links': [{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'self'}, {
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'bookmark'}, {
u'href': u'https://cyclades.okeanos.grnet.gr/image/v1.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'alternate'}]},
u'suspended': False,
u'flavor': {u'id': 3, u'links': [
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/flavors/3',
u'rel': u'self'},
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/flavors/3',
u'rel': u'bookmark'}]},
u'id': 664664,
u'security_groups': [{u'name': u'default'}],
u'attachments': [],
u'user_id': u'19e4daba-20e2-4d57-a6aa-92ba1c982fd9',
u'accessIPv4': u'', u'accessIPv6': u'',
u'progress': 0, u'config_drive': u'',
u'status': u'BUILD',
u'updated': u'2015-07-08T10:15:38.936455+00:00',
u'hostId': u'',
u'SNF:fqdn': u'snf-661243.vm.okeanos.grnet.gr',
u'deleted': False, u'key_name': None,
u'name': u'to mikro debian sto livadi',
u'adminPass': u'X9yqjSTAFO',
u'tenant_id': u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f',
u'created': u'2015-07-08T10:15:37.837229+00:00',
u'SNF:task_state': u'BUILDING',
u'volumes': [50369], u'diagnostics': [],
u'metadata': {u'os': u'debian',
u'users': u'root ckaner'},
u'SNF:port_forwarding': {}}],
"slaves": [{u'addresses': {}, u'links': [
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'self'},
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'bookmark'}],
u'image': {
u'id': u'0e399015-8723-4c78-8198-75bdf693cdde',
u'links': [{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'self'}, {
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'bookmark'}, {
u'href': u'https://cyclades.okeanos.grnet.gr/image/v1.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'alternate'}]},
u'suspended': False,
u'flavor': {u'id': 3, u'links': [
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/flavors/3',
u'rel': u'self'},
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/flavors/3',
u'rel': u'bookmark'}]},
u'id': 664664,
u'security_groups': [{u'name': u'default'}],
u'attachments': [],
u'user_id': u'19e4daba-20e2-4d57-a6aa-92ba1c982fd9',
u'accessIPv4': u'', u'accessIPv6': u'',
u'progress': 0, u'config_drive': u'',
u'status': u'BUILD',
u'updated': u'2015-07-08T10:15:38.936455+00:00',
u'hostId': u'',
u'SNF:fqdn': u'snf-661526.vm.okeanos.grnet.gr',
u'deleted': False, u'key_name': None,
u'name': u'to mikro debian sto livadi',
u'adminPass': u'X9yqjSTAFO',
u'tenant_id': u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f',
u'created': u'2015-07-08T10:15:37.837229+00:00',
u'SNF:task_state': u'BUILDING',
u'volumes': [50369], u'diagnostics': [],
u'metadata': {u'os': u'debian',
u'users': u'root ckaner'},
u'SNF:port_forwarding': {}},
{u'addresses': {}, u'links': [
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'self'},
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'bookmark'}], u'image': {
u'id': u'0e399015-8723-4c78-8198-75bdf693cdde',
u'links': [{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'self'}, {
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'bookmark'}, {
u'href': u'https://cyclades.okeanos.grnet.gr/image/v1.0/images/0e399015-8723-4c78-8198-75bdf693cdde',
u'rel': u'alternate'}]},
u'suspended': False,
u'flavor': {u'id': 3, u'links': [
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/flavors/3',
u'rel': u'self'},
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/flavors/3',
u'rel': u'bookmark'}]},
u'id': 664664,
u'security_groups': [{u'name': u'default'}],
u'attachments': [],
u'user_id': u'19e4daba-20e2-4d57-a6aa-92ba1c982fd9',
u'accessIPv4': u'',
u'accessIPv6': u'', u'progress': 0,
u'config_drive': u'', u'status': u'BUILD',
u'updated': u'2015-07-08T10:15:38.936455+00:00',
u'hostId': u'',
u'SNF:fqdn': u'snf-661527.vm.okeanos.grnet.gr',
u'deleted': False, u'key_name': None,
u'name': u'to mikro debian sto livadi',
u'adminPass': u'X9yqjSTAFO',
u'tenant_id': u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f',
u'created': u'2015-07-08T10:15:37.837229+00:00',
u'SNF:task_state': u'BUILDING',
u'volumes': [50369], u'diagnostics': [],
u'metadata': {u'os': u'debian',
u'users': u'root ckaner'},
u'SNF:port_forwarding': {}}]}
from provisioner import Provisioner
provisioner = Provisioner("lambda")
inv = provisioner.create_lambda_cluster("test_vm")
# provisioner = Provisioner("lambda")
# inv = provisioner.create_lambda_cluster("test_vm")
manager = Manager(inv, provisioner)
manager.create_inventory(provisioner.get_server_private_ip())
# manager.run_playbook(playbook_file="../../ansible/playbooks/testinventory.yml", tags=["touch"])
manager.run_playbook(playbook_file="../../ansible/playbooks/testproxy.yml", tags=["install"])
manager = Manager(inv)
manager.create_inventory()
manager.run_playbook(playbook_file="../../ansible/playbooks/testinventory.yml")
# manager.run_playbook(playbook_file="../../ansible/playbooks/testproxy.yml", tags=["install"])
Markdown is supported
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