From 07205aad937a08900035c1bf5ce916255de112e2 Mon Sep 17 00:00:00 2001 From: Patrick DOUCHEMENT Date: Fri, 11 Aug 2017 10:14:34 +0200 Subject: [PATCH 1/2] create byon location for alien1.3.4 --- .../playbook/connect_hostpool.yml | 13 +++ .../create_byon_location_resource.yml | 13 +++ .../cfy_byon_v1.3.4/playbook/inputs.json.tpl | 16 ++++ .../cfy_byon_v1.3.4/playbook/playbook.ansible | Bin 0 -> 4816 bytes .../roles/connect_hostpool/tasks/main.yml | 18 ++++ .../tasks/main.yml | 72 +++++++++++++++ .../playbook/roles/setup/tasks/main.yml | 52 +++++++++++ .../cfy_byon_v1.3.4/types.yml | 84 ++++++++++++++++++ 8 files changed, 268 insertions(+) create mode 100644 org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/connect_hostpool.yml create mode 100644 org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/create_byon_location_resource.yml create mode 100644 org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/inputs.json.tpl create mode 100644 org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/playbook.ansible create mode 100644 org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/connect_hostpool/tasks/main.yml create mode 100644 org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/create_byon_location_resource/tasks/main.yml create mode 100644 org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/setup/tasks/main.yml create mode 100644 org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/types.yml diff --git a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/connect_hostpool.yml b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/connect_hostpool.yml new file mode 100644 index 00000000..43d63fc7 --- /dev/null +++ b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/connect_hostpool.yml @@ -0,0 +1,13 @@ +--- +- hosts: all + name: Connect to hostpool + become: true + + pre_tasks: + - name: Debug vars + debug: + msg: "{{ vars | to_json }}" + + roles: + - setup + - connect_hostpool diff --git a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/create_byon_location_resource.yml b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/create_byon_location_resource.yml new file mode 100644 index 00000000..2073fcba --- /dev/null +++ b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/create_byon_location_resource.yml @@ -0,0 +1,13 @@ +--- +- hosts: all + name: Add BYON on-demand resource + become: true + + pre_tasks: + - name: Debug vars + debug: + msg: "{{ vars | to_json }}" + + roles: + - setup + - create_byon_location_resource diff --git a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/inputs.json.tpl b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/inputs.json.tpl new file mode 100644 index 00000000..63d7d30f --- /dev/null +++ b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/inputs.json.tpl @@ -0,0 +1,16 @@ +{ +"NODE": "Test", +"INSTANCE": "Test", +"SOURCE_NODE": "Test", +"SOURCE_INSTANCE": "Test", +"alien_url": "http://localhost:8088", +"alien_user": "admin", +"alien_password": "admin", +"cfy_url": "https://52.48.126.116:443", +"cfy_user": "admin", +"cfy_password": "ad1min", +"name": "CFYOrchestrator", +"pluginId": "alien-cloudify-4-orchestrator-premium", +"pluginBean": "cloudify-orchestrator", +"disableDiamondMonitorAgent": "true" +} diff --git a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/playbook.ansible b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/playbook.ansible new file mode 100644 index 0000000000000000000000000000000000000000..430753a98a7d7b09ba5eb5bf84bfdbb6c494fff0 GIT binary patch literal 4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=@GUgcDMQsB2J03U%#kA8AL~m@bt~DPJhyqqhUfiJ9g&oP zGkVjmQ;pKB#$6ZD^&GFXRnyZ>$fpE$-dDdskk4g)^ilN-#=9>K&TPNUy|(v2PT=LZ z;^uw0!Cv1suXxgcSXNPdm-HLY9b2#tgRo1_8<_Kcb(=nCiYAL&vr(fX1<4dECmm3QMT=}PPUmu6`G5bGREPrg?8EV1`}hZ^rwjt zt#xH1JECv(5lIc61tRb~v8XGxCP$Reah9Xv<#I=N&hG1o70@9NT1V96?z%fS_?=cn z{2^Y_5YwEba9foSs@d$~)cLR-TP17qLe}&%yEUAFao_S5<7XQW%6ozG!7cy&`8I?N z*t&d{0T2do7I{8%AD=ReZ-!U|@ex-dJ!Sodfu2$f=K9C&13eOm9KukL-?XVnTBJv= zxAgSLFmQIz8T>WLIn_&EgUPvEsL5%OKKXi+OrJawe6P_Zr&wls0M6Kb3K)ONAbF7r zpv6_d&uk|RzypePm5Jt+=<@;+GHqjE;g?c2Ef2){ysXQvYpqqK<;8({Ygh8F7}qs` z@5(5bPz$F;`ohtjxBmKIl=UH^7c0O+YX|C0J^p~L-t#byQ8n?o9VE7xagoMQb< exists" + file: + path: "{{ file_dir }}" + state: directory + when: hostpool_url is defined + +- name: "Echo <{{ hostpool_url }}> into {{ file_path }}" + shell: "echo '{{ hostpool_url }}' > {{ file_path }}" + when: hostpool_url is defined diff --git a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/create_byon_location_resource/tasks/main.yml b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/create_byon_location_resource/tasks/main.yml new file mode 100644 index 00000000..5a9fb8be --- /dev/null +++ b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/create_byon_location_resource/tasks/main.yml @@ -0,0 +1,72 @@ +--- + +# read hostpool_url from hostpool connection +- name: Check relationship inputs exists + stat: path="/tmp/a4cPlaybookRegistry/{{ NODE }}/{{ INSTANCE }}/connect_hostpool/inputs/hostpool_url" + register: hostpool_url_file +- name: read relationship inputs + command: /bin/cat "/tmp/a4cPlaybookRegistry/{{ NODE }}/{{ INSTANCE }}/connect_hostpool/inputs/hostpool_url" + register: hostpool_url_content + when: hostpool_url_file.stat.exists +- set_fact: + hostpool_url: "{{ hostpool_url_content.stdout_lines[0] }}" + when: hostpool_url_file.stat.exists and hostpool_url_content.stdout_lines|length > 0 + +- name: login + uri: + url: "{{ alien_url }}/login?username={{ alien_user }}&password={{ alien_password }}&submit=Login" + method: POST + return_content: yes + status_code: 302 + headers: + Content-Type: "application/x-www-form-urlencoded" + register: login + +- set_fact: + session_id: "{{ login.set_cookie.split(';')[0] }}" + +- name: Create on-demand location resource + uri: + url: "{{ alien_url }}/rest/latest/orchestrators/{{ orchestratorId }}/locations/{{ locationId }}/resources" + method: POST + return_content: yes + HEADER_cookie: "{{ session_id }}" + body: + resourceType: "{{ resourceType }}" + resourceName: "{{ resourceName }}" + archiveName: "{{ resourceArchiveName }}" + archiveVersion: "{{ resourceArchiveVersion }}" + id: "{{ resourceType }}:{{ resourceArchiveVersion }}" + body_format: json + status_code: 200 + register: result + +- set_fact: + resourceId: "{{ result.json.data.resourceTemplate.id }}" + +- name: Configure on-demand location resource + uri: + url: "{{ alien_url }}/rest/latest/orchestrators/{{ orchestratorId }}/locations/{{ locationId }}/resources/{{ resourceId }}/template/properties" + method: POST + return_content: yes + HEADER_cookie: "{{ session_id }}" + body: + propertyName: "host_pool_service_endpoint" + propertyValue: "{{ hostpool_url }}" + body_format: json + status_code: 200 + register: result + +- name: Configure on-demand location resource + uri: + url: "{{ alien_url }}/rest/latest/orchestrators/{{ orchestratorId }}/locations/{{ locationId }}/resources/{{ resourceId }}/template/properties" + method: POST + return_content: yes + HEADER_cookie: "{{ session_id }}" + body: + propertyName: "agent_config" + propertyValue: + install_method: "{{ resourceAgentInstallMethod }}" + body_format: json + status_code: 200 + register: result diff --git a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/setup/tasks/main.yml b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/setup/tasks/main.yml new file mode 100644 index 00000000..0109dc75 --- /dev/null +++ b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/playbook/roles/setup/tasks/main.yml @@ -0,0 +1,52 @@ +- name: Add repository + yum: + name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + state: present + when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'RedHat' + +# Install system dependencies (Centos Redhat) +- name: Install system dependencies + yum: pkg={{ item }} state=present + with_items: + - gcc + - python-devel + when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'RedHat' + +# Install system dependencies (Ubuntu) +- name: Preprare apt cache + apt: + update_cache: yes + when: ansible_distribution == 'Ubuntu' + +- name: Install system dependencies (Ubuntu) + apt: name={{item}} state=installed + with_items: + - gcc + - python-dev + when: ansible_distribution == 'Ubuntu' + +# Install pip +- name: Download get-pip.py + get_url: + url: "https://bootstrap.pypa.io/get-pip.py" + dest: /tmp/get-pip.py + +- name: Check python-pip exists + stat: path=/usr/bin/pip + register: pip_cmd + +- name: Install python-pip + command: python /tmp/get-pip.py + when: not pip_cmd.stat.exists + +- name: Install pip + yum: pkg=python-pip state=present + when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'RedHat' + +- name: Ensure httplib2 & boto are present + pip: + name: "{{ item }}" + state: present + with_items: + - httplib2 + - boto diff --git a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/types.yml b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/types.yml new file mode 100644 index 00000000..3e9cb1e6 --- /dev/null +++ b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/types.yml @@ -0,0 +1,84 @@ +tosca_definitions_version: alien_dsl_1_4_0 + +metadata: + template_name: org.alien4cloud.automation.a4c.config.location_resources.cfy_byon_v1-3-4 + template_version: 1.4.0-SNAPSHOT + template_author: alien4cloud + +imports: + - alien-base-types:1.4.0 + - org.alien4cloud.automation.a4c.config.location:1.4.0-SNAPSHOT + - org.alien4cloud.automation.cloudify.hostpool.pub:1.4.0-SNAPSHOT + - org.alien4cloud.automation.cloudify.manager.pub:1.4.0-SNAPSHOT + - tosca-normative-types:1.0.0-ALIEN14 + +node_types: + + org.alien4cloud.automation.a4c.config.location_resources.cfy_byon_v1-3-4.nodes.ByonLocationResourcesConfigurator: + description: | + Configure a BYON location for A4C 1.3.4 with a single on-demand resource + derived_from: org.alien4cloud.automation.a4c.config.location.nodes.SimpleLocationConfigurator + properties: + type: + type: string + required: true + default: byon + constraints: + - valid_values: [ "byon" ] + resourceType: + type: string + required: true + default: alien.cloudify.byon.nodes.LinuxCompute + resourceName: + type: string + required: true + default: MyResource + resourceArchiveName: + type: string + required: true + default: cloudify-byon-types + resourceArchiveVersion: + type: string + required: true + default: 1.4.0 + resourceAgentInstallMethod: + type: string + required: true + default: none + requirements: + - hostpool: + capability: org.alien4cloud.automation.cloudify.hostpool.pub.capabilities.HostPoolServiceApi + relationship: org.alien4cloud.automation.a4c.config.location_resources.cfy_byon_v1-3-4.LocationConnectsToHostpool + occurrences: [1, 1] + interfaces: + Standard: + start: + # create the location on demand resources + inputs: + ANSIBLE_VERBOSE: false + PLAYBOOK_ENTRY: create_byon_location_resource.yml + orchestratorId: { get_attribute: [HOST, orchestratorId] } + locationId: { get_attribute: [SELF, locationId] } + alien_url: { get_attribute: [HOST, alien_url] } + alien_user: { get_attribute: [HOST, alien_user] } + alien_password: { get_attribute: [HOST, alien_password] } + resourceType: { get_property: [SELF, resourceType] } + resourceName: { get_property: [SELF, resourceName] } + resourceArchiveName: { get_property: [SELF, resourceArchiveName] } + resourceArchiveVersion: { get_property: [SELF, resourceArchiveVersion] } + resourceAgentInstallMethod: { get_property: [SELF, resourceAgentInstallMethod] } + implementation: playbook/playbook.ansible + +relationship_types: + + org.alien4cloud.automation.a4c.config.location_resources.cfy_byon_v1-3-4.LocationConnectsToHostpool: + derived_from: tosca.relationships.ConnectsTo + valid_target_types: [ org.alien4cloud.automation.cloudify.hostpool.pub.capabilities.HostPoolServiceApi ] + interfaces: + Configure: + pre_configure_source: + inputs: + ANSIBLE_VERBOSE: false + PLAYBOOK_ENTRY: connect_hostpool.yml + hostpool_url: { concat: [get_property: [TARGET, cloudify_hostpool, protocol], "://", get_attribute: [TARGET, cloudify_hostpool, ip_address], ":", get_property: [TARGET, cloudify_hostpool, port]] } + implementation: playbook/playbook.ansible From 5144cbb99900e31dfac2c4b9fc92ce5d3131287f Mon Sep 17 00:00:00 2001 From: Patrick DOUCHEMENT Date: Mon, 21 Aug 2017 11:55:12 +0200 Subject: [PATCH 2/2] update resourceArchiveVersion --- .../a4c/config/location_resources/cfy_byon_v1.3.4/types.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/types.yml b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/types.yml index 3e9cb1e6..0cd8770a 100644 --- a/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/types.yml +++ b/org/alien4cloud/automation/a4c/config/location_resources/cfy_byon_v1.3.4/types.yml @@ -40,7 +40,7 @@ node_types: resourceArchiveVersion: type: string required: true - default: 1.4.0 + default: 1.3.4 resourceAgentInstallMethod: type: string required: true