Commit fdb97c0f authored by Spiros Koulouzis's avatar Spiros Koulouzis

made interface input 'playbook' into a list

parent fb8231a1
......@@ -63,13 +63,16 @@ topology_template:
Standard:
configure:
inputs:
playbook: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/k8s_dashboard.yaml"
repository: https://github.com/skoulouzis/playbooks.git
playbook: "k8s_dashboard.yaml"
create:
inputs:
playbook: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/install_k8s.yaml"
playbook: "install_k8s.yaml"
repository: https://github.com/skoulouzis/playbooks.git
delete:
inputs:
playbook: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/k8s_delete.yaml"
playbook: "k8s_delete.yaml"
repository: https://github.com/skoulouzis/playbooks.git
type: "tosca.nodes.ARTICONF.docker.Orchestrator.Kubernetes"
topology:
properties:
......
......@@ -29,15 +29,15 @@ topology_template:
repository: docker_hub
#topology:
#type: tosca.nodes.ARTICONF.VM.topology
#interfaces:
#CloudsStorm:
#provision:
#inputs:
#code_type: SEQ
#object_type: SubTopology
#properties:
#domain: UvA (Amsterdam, The Netherlands) XO Rack
#provider: ExoGENI
topology:
type: tosca.nodes.ARTICONF.VM.topology
interfaces:
CloudsStorm:
provision:
inputs:
code_type: SEQ
object_type: SubTopology
properties:
domain: UvA (Amsterdam, The Netherlands) XO Rack
provider: ExoGENI
......@@ -68,7 +68,7 @@ interface_types:
inventory_file:
type: string
required: false
playbook:
playbooks:
type: string
required: false
repository:
......@@ -84,8 +84,8 @@ interface_types:
repository:
type: string
required: false
playbook:
type: string
playbooks:
type: list
required: false
replicas:
type: integer
......
......@@ -135,15 +135,22 @@ node_types:
create:
inputs:
repository: https://github.com/skoulouzis/playbooks.git
playbook: install_k8s.yaml
playbooks:
- install_packages.yaml
- mount.yaml
- install_docker.yaml
- install_k8s.yaml
configure:
inputs:
repository: https://github.com/skoulouzis/playbooks.git
playbook: k8s_dashboard.yaml
playbooks:
- create_k8s_cluster.yaml
- create_k8s_dashboard.yaml
delete:
inputs:
repository: https://github.com/skoulouzis/playbooks.git
playbook: k8s_delete.yaml
playbooks:
- k8s_delete.yaml
tosca.nodes.ARTICONF.VM.topology:
......
- hosts: all
become: yes
tasks:
#- name: replace DNS
#shell: sed -i "s/nameserver.*/nameserver 8.8.8.8/g" /etc/resolv.conf
#- name: replace DNS
#lineinfile:
#path: /etc/resolv.conf
#regexp: 'nameserver.*'
#line: nameserver 8.8.8.8
- name: Wait for automatic system updates
shell: while sudo fuser /var/lib/dpkg/{{ item }} >/dev/null 2>&1; do sleep 3; done;
with_items:
- lock
- lock-frontend
- name: Update and upgrade apt packages
apt:
upgrade: yes
update_cache: yes
- name: Install aptitude using apt
apt: name=aptitude state=latest update_cache=yes force_apt_get=yes
- name: Install required of packages
apt:
name: "{{ packages }}"
update_cache: yes
vars:
packages:
- ca-certificates
- apt-transport-https
- curl
- gnupg2
- software-properties-common
- python3-pip
- python-pip
- virtualenv
- name: Check that the /dev/xvdh exists
stat:
path: /dev/xvdh
register: mount_volume
- debug:
msg: "/dev/xvdh exists"
when: mount_volume.stat.exists
- name: Create a xfs
filesystem:
fstype: xfs
dev: /dev/xvdh
when: mount_volume.stat.exists == True
- name: Creates directory
file:
path: /data
state: directory
when: mount_volume.stat.exists == True
- name: Mount
mount:
path: /data
src: /dev/xvdh
state: present
fstype: xfs
when: mount_volume.stat.exists == True
- name: check Mount
command: mountpoint -q /data
register: volume_stat
failed_when: False
changed_when: False
- debug:
msg: volume_stat.rc {{ volume_stat.rc }}
when: mount_volume.stat.exists
- name: Mount manualy
shell: 'mount /dev/xvdh /data'
when: mount_volume.stat.exists
ignore_errors: yes
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu bionic stable
state: present
- name: Update apt and install docker-ce
apt: update_cache=yes name=docker-ce state=latest
- name: Update and upgrade apt packages
apt:
upgrade: yes
update_cache: yes
- name: Add the Kubernetes signing key
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb http://apt.kubernetes.io/ kubernetes-xenial main
state: present
- name: Update apt and install docker-ce
apt: update_cache=yes name=kubeadm state=latest
- name: Change data-root location in /etc/docker/daemon.json
shell: |
echo '{"data-root": "/data"}' > /etc/docker/daemon.json
when: mount_volume.stat.exists == True
- name: Restart service docker, in all cases
service:
name: docker
state: restarted
ignore_errors: yes
when: mount_volume.stat.exists == True
all:
vars:
ansible_ssh_user: ubunut
host_key_checking: False
children:
k8-master:
hosts:
192.168.1.10:
worker:
hosts:
192.168.1.11:
192.168.1.12:
192.168.1.13:
......@@ -62,17 +62,10 @@ class AnsibleService:
if self.semaphore_helper.get_task(project_id,task_id).status == 'success':
task_id = self.run_task(name, project_id, key_id, git_url, inventory_id, playbook_name)
pass
def build_yml_inventory(self, vms):
# loader = DataLoader()
# inventory = InventoryManager(loader=loader)
# variable_manager = VariableManager()
# with open(r'/home/alogo/Downloads/inventory.yaml') as file:
# # The FullLoader parameter handles the conversion from YAML
# # scalar values to Python the dictionary format
# data = yaml.load(file)
inventory = {}
all = {}
vars = {'ansible_ssh_common_args':'-o StrictHostKeyChecking=no'}
......@@ -82,12 +75,13 @@ class AnsibleService:
attributes = vm.node_template.attributes
role = attributes['role']
public_ip = attributes['public_ip']
if role not in children:
hosts = {}
else:
hosts = children[role]
hosts[public_ip] = vars
host = {}
host[public_ip] = vars
hosts['hosts'] = host
children[role] = hosts
# inventory.add_group(role)
# inventory.add_host(public_ip,group=role)
......
......@@ -21,7 +21,4 @@ class DeployService:
if interface_types and 'Standard' in interface_types:
ansible_service = AnsibleService(self.semaphore_base_url,self.semaphore_username,self.semaphore_password)
ansible_service.execute(nodes_pair)
# print(source)
# print(target)
return None
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