Initial CDN deployment playbooks and ansible modules
Change-Id: Ib2c5a8f3d22459bf3c540289f7b7cc1b3fdf4457
diff --git a/setup/roles/cdn-cord-profile/files/cdn_service.yml b/setup/roles/cdn-cord-profile/files/cdn_service.yml
new file mode 100644
index 0000000..f83e4d0
--- /dev/null
+++ b/setup/roles/cdn-cord-profile/files/cdn_service.yml
@@ -0,0 +1,111 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Setup the CDN on the pod
+
+imports:
+ - custom_types/xos.yaml
+
+topology_template:
+ node_templates:
+
+ Private:
+ type: tosca.nodes.NetworkTemplate
+
+ management:
+ type: tosca.nodes.network.Network.XOS
+ properties:
+ no-create: true
+ no-delete: true
+ no-update: true
+
+# cdn-public:
+# type: tosca.nodes.network.Network
+# properties:
+# ip_version: 4
+# cidr: 207.141.192.128/28
+# requirements:
+# - network_template:
+# node: Private
+# relationship: tosca.relationships.UsesNetworkTemplate
+# - owner:
+# node: mysite_cdn
+# relationship: tosca.relationships.MemberOfSlice
+# - connection:
+# node: mysite_cdn
+# relationship: tosca.relationships.ConnectsToSlice
+
+ mysite:
+ type: tosca.nodes.Site
+
+ public:
+ type: tosca.nodes.network.Network.XOS
+ properties:
+ no-create: true
+ no-delete: true
+ no-update: true
+
+ service#cdn:
+ type: tosca.nodes.Service
+ properties:
+ public_key: { get_artifact: [ SELF, pubkey, LOCAL_FILE] }
+ private_key_fn: /opt/xos/services/cdn/keys/amc_id_rsa
+ artifacts:
+ pubkey: /opt/cord_profile/key_import/cdnnode_id_rsa.pub
+
+ mysite_cdn_control:
+ description: This slice holds the controller for the CDN
+ type: tosca.nodes.Slice
+ properties:
+ network: noauto
+ requirements:
+ - site:
+ node: mysite
+ relationship: tosca.relationships.MemberOfSite
+ - management:
+ node: management
+ relationship: tosca.relationships.ConnectsToNetwork
+ - public:
+ node: public
+ relationship: tosca.relationships.ConnectsToNetwork
+ - cdn_service:
+ node: service#cdn
+ relationship: tosca.relationships.MemberOfService
+
+
+ mysite_cdn_nodes:
+ description: This slice holds the hypercache/rr nodes for the CDN
+ type: tosca.nodes.Slice
+ properties:
+ network: noauto
+ requirements:
+ - site:
+ node: mysite
+ relationship: tosca.relationships.MemberOfSite
+ - management:
+ node: management
+ relationship: tosca.relationships.ConnectsToNetwork
+ - public:
+ node: public
+ relationship: tosca.relationships.ConnectsToNetwork
+ - cdn_service:
+ node: service#cdn
+ relationship: tosca.relationships.MemberOfService
+
+ mysite_cdn_cli:
+ description: This slice holds the hypercache/rr nodes for the CDN
+ type: tosca.nodes.Slice
+ properties:
+ network: noauto
+ requirements:
+ - site:
+ node: mysite
+ relationship: tosca.relationships.MemberOfSite
+ - management:
+ node: management
+ relationship: tosca.relationships.ConnectsToNetwork
+ - public:
+ node: public
+ relationship: tosca.relationships.ConnectsToNetwork
+ - cdn_service:
+ node: service#cdn
+ relationship: tosca.relationships.MemberOfService
\ No newline at end of file
diff --git a/setup/roles/cdn-cord-profile/files/setup_headnode.yml b/setup/roles/cdn-cord-profile/files/setup_headnode.yml
new file mode 100644
index 0000000..edf2aa4
--- /dev/null
+++ b/setup/roles/cdn-cord-profile/files/setup_headnode.yml
@@ -0,0 +1,21 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Some basic fixtures
+
+imports:
+ - custom_types/xos.yaml
+
+topology_template:
+ node_templates:
+ m1.cdnnode:
+ type: tosca.nodes.Flavor
+
+ image#AMC:
+ type: tosca.nodes.Image
+ properties:
+ path: /opt/xos/images/AMC.qcow2
+
+ image#CentOS-6-cdnnode-0.4:
+ type: tosca.nodes.Image
+ properties:
+ path: /opt/xos/images/CentOS-6-cdnnode-0.4.qcow2
diff --git a/setup/roles/cdn-cord-profile/tasks/main.yml b/setup/roles/cdn-cord-profile/tasks/main.yml
new file mode 100644
index 0000000..5110500
--- /dev/null
+++ b/setup/roles/cdn-cord-profile/tasks/main.yml
@@ -0,0 +1,16 @@
+---
+
+- name: Copy over commonly used and utility TOSCA files
+ copy:
+ src: "{{ item }}"
+ dest: "/opt/cord_profile/{{ item }}"
+ with_items:
+ - setup_headnode.yml
+ - cdn_service.yml
+
+- name: Copy over the public key
+ copy:
+ src: "{{ item }}"
+ dest: "/opt/cord_profile/key_import/{{ item }}"
+ with_items:
+ - cdnnode_id_rsa.pub
diff --git a/setup/roles/cdn-xos-config/defaults/main.yml b/setup/roles/cdn-xos-config/defaults/main.yml
new file mode 100644
index 0000000..12210de
--- /dev/null
+++ b/setup/roles/cdn-xos-config/defaults/main.yml
@@ -0,0 +1,3 @@
+---
+
+xos_admin_user: "xosadmin@opencord.org"
diff --git a/setup/roles/cdn-xos-config/tasks/main.yml b/setup/roles/cdn-xos-config/tasks/main.yml
new file mode 100644
index 0000000..67edd97
--- /dev/null
+++ b/setup/roles/cdn-xos-config/tasks/main.yml
@@ -0,0 +1,10 @@
+---
+# xos-config/tasks/main.yml
+
+- name: Setup cdn-specific objects
+ command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} /opt/cord_profile/{{ item }}"
+ with_items:
+ - "setup_headnode.yml"
+ - "cdn_service.yml"
+ tags:
+ - skip_ansible_lint # TOSCA loading should be idempotent
\ No newline at end of file
diff --git a/setup/roles/generate-inventory/tasks/main.yml b/setup/roles/generate-inventory/tasks/main.yml
new file mode 100644
index 0000000..9eaf267
--- /dev/null
+++ b/setup/roles/generate-inventory/tasks/main.yml
@@ -0,0 +1,8 @@
+- name: create config file
+ local_action: template src=cmi.conf.j2 dest={{ playbook_dir }}/cmi.conf
+
+- name: create inventory file
+ local_action: template src=cmi-inventory.j2 dest={{ playbook_dir }}/cmi-inventory
+
+- name: create ssh-cmi.sh file
+ local_action: template src=ssh-cmi.sh.j2 dest={{ playbook_dir }}/ssh-cmi.sh mode=0777
diff --git a/setup/roles/generate-inventory/templates/cmi-inventory.j2 b/setup/roles/generate-inventory/templates/cmi-inventory.j2
new file mode 100644
index 0000000..f48da15
--- /dev/null
+++ b/setup/roles/generate-inventory/templates/cmi-inventory.j2
@@ -0,0 +1 @@
+cmi ansible_ssh_private_key_file={{ cmi_private_key }} ansible_user={{ cmi_root_user }}
diff --git a/setup/roles/generate-inventory/templates/cmi.conf.j2 b/setup/roles/generate-inventory/templates/cmi.conf.j2
new file mode 100644
index 0000000..43df5f6
--- /dev/null
+++ b/setup/roles/generate-inventory/templates/cmi.conf.j2
@@ -0,0 +1,6 @@
+[ssh_connection]
+ssh_args = -o "ProxyCommand ssh -q -i {{ cmi_compute_node_key }} -o StrictHostKeyChecking=no root@{{ cmi_compute_node }} nc {{ cmi_mgmt_ip }} 22"
+scp_if_ssh = True
+pipelining = True
+[defaults]
+host_key_checking = False
diff --git a/setup/roles/generate-inventory/templates/ssh-cmi.sh.j2 b/setup/roles/generate-inventory/templates/ssh-cmi.sh.j2
new file mode 100644
index 0000000..aaa42af
--- /dev/null
+++ b/setup/roles/generate-inventory/templates/ssh-cmi.sh.j2
@@ -0,0 +1,2 @@
+#! /bin/bash
+ssh -i {{ cmi_private_key }} -o "ProxyCommand ssh -q -i {{ cmi_compute_node_key }} -o StrictHostKeyChecking=no root@{{ cmi_compute_node }} nc {{ cmi_mgmt_ip }} 22" {{ cmi_root_user }}@cmi
diff --git a/setup/roles/setup-cmi/tasks/main.yml b/setup/roles/setup-cmi/tasks/main.yml
new file mode 100644
index 0000000..8393efc
--- /dev/null
+++ b/setup/roles/setup-cmi/tasks/main.yml
@@ -0,0 +1,25 @@
+---
+#- name: fix the networking
+# shell: "{{ item }}"
+# with_items:
+# - ifconfig {{ eth_device }} hw ether {{ eth_mac }}
+# - ip route del default || true
+# - ip route add default via {{ gateway_ip }}
+# - arp -s {{ gateway_ip }} {{ gateway_mac }}
+
+
+- name: download socat
+ get_url: url=http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el6/en/x86_64/rpmforge/RPMS/socat-1.7.1.3-1.el6.rf.x86_64.rpm dest=/root/socat-1.7.1.3-1.el6.rf.x86_64.rpm
+
+- name: install socat
+ yum: name=/root/socat-1.7.1.3-1.el6.rf.x86_64.rpm state=present
+
+- name: copy over setup answers
+ template:
+ src: templates/setup_answers.txt.j2
+ dest: /root/setup_answers.txt
+
+- name: run the setup script
+ shell: /a/sbin/setup.sh < /root/setup_answers.txt
+ args:
+ creates: /a/var/log/setup.log
diff --git a/setup/roles/setup-cmi/templates/setup_answers.txt.j2 b/setup/roles/setup-cmi/templates/setup_answers.txt.j2
new file mode 100644
index 0000000..50aa853
--- /dev/null
+++ b/setup/roles/setup-cmi/templates/setup_answers.txt.j2
@@ -0,0 +1,19 @@
+y
+{{ cmi_password }}
+{{ cmi_password }}
+n
+{{ eth_device }}
+y
+{{ cmi_domain }}
+{{ cmi_hostname }}
+{{ eth_device }}
+
+
+{{ cdn_site }}
+{{ cdn_short_name }}
+{{ cmi_dns }}
+
+{{ cdn_name }}
+{{ cmi_password }}
+{{ cmi_password }}
+y