Skip to content
Snippets Groups Projects
Commit d178beee authored by Pelle Jakovits's avatar Pelle Jakovits Committed by Michael Wurster
Browse files

Adding Ansible implementations to NiFi node types (#1)

* Adding Ansible implementations to NiFi node types
* Fixed file paths in NiFiPipeline node type definition interfaces
parent 3ae68e7a
No related branches found
Tags v1.0.0
No related merge requests found
Showing
with 187 additions and 2 deletions
......@@ -30,4 +30,21 @@ node_types:
capabilities:
host:
type: tosca.capabilities.Container
valid_source_types: [ radon.nodes.apache.nifi.NifiPipeline ]
\ No newline at end of file
valid_source_types: [ radon.nodes.apache.nifi.NifiPipeline ]
interfaces:
Standard:
type: tosca.interfaces.node.lifecycle.Standard
create:
inputs:
tarball_version: { default: { get_property: [ SELF, component_version ] } }
implementation: files/create.yml
start:
implementation: files/start.yml
stop:
implementation: files/stop.yml
configure:
implementation: files/configure.yml
delete:
inputs:
tarball_version: { default: { get_property: [ SELF, component_version ] } }
implementation: files/delete.yml
---
- hosts: all
---
- hosts: all
become: yes
tasks:
- name: Install Java 8
package:
name: "java-1.8.0-openjdk.x86_64"
state: present
- name: Download and unpack NiFi binary distribution
unarchive:
src: https://www-eu.apache.org/dist/nifi/{{ tarball_version }}/nifi-{{ tarball_version }}-bin.tar.gz
dest: /usr/local/bin
remote_src: yes
creates: /usr/local/bin/nifi-{{ tarball_version }}/LICENSE
- name: Install nifi service
shell: "/usr/local/bin/nifi-{{ tarball_version }}/bin/nifi.sh install"
args:
executable: /bin/bash
---
- hosts: all
become: yes
tasks:
- name: Delete NiFi files
file:
state: absent
path: "/usr/local/bin/{{ tarball_version }}/"
---
- hosts: all
become: yes
tasks:
- name: Start nifi service
service:
name: nifi
enabled: yes
state: started
---
- hosts: all
become: yes
tasks:
- name: Stop nifi service
service:
name: nifi
enabled: no
state: stopped
......@@ -38,4 +38,28 @@ node_types:
type: tosca.capabilities.Endpoint
description: Capability to receive data from other pipeline nodes
valid_source_type: [ radon.nodes.apache.nifi.NifiPipeline ]
occurrences: [0, UNBOUNDED]
\ No newline at end of file
occurrences: [0, UNBOUNDED]
interfaces:
Standard:
type: tosca.interfaces.node.lifecycle.Standard
create:
inputs:
template_file: { default: { get_artifact: [ SELF, pipeline_template ] } }
template_name: { default: { get_property: [ SELF, name ] } }
implementation: files/create.yml
start:
inputs:
pipeline_id: { default: { get_attribute: [ SELF, id ] } }
implementation: files/start.yml
stop:
inputs:
pipeline_id: { default: { get_attribute: [ SELF, id ] } }
implementation: files/stop.yml
configure:
inputs:
pipeline_id: { default: { get_attribute: [ SELF, id ] } }
implementation: files/configure.yml
delete:
inputs:
pipeline_id: { default: { get_attribute: [ SELF, id ] } }
implementation: files/delete.yml
---
- hosts: all
---
- hosts: all
vars:
query: "resources[?name=='{{template_name}}' && starts_with(identifier, '/templates/')].identifier"
tasks:
- name: Copy template file to remote system (shell command requires file to be in remote system)
copy:
src: "{{ template_file }}"
dest: template.xml
- name: Wait for port 8080 to become open on the host, don't start checking for 4 seconds
wait_for:
port: 8080
delay: 4
- name: upload template file to NiFi template repository
shell: 'curl -X "POST" "http://localhost:8080/nifi-api/process-groups/root/templates/upload" \
-H "Content-Type: multipart/form-data; charset=utf-8; boundary=__X_PAW_BOUNDARY__" \
-k \
--form template=@template.xml'
register: response
- name: Get list of available NiFi resources for fetching the id of the template by its name
uri:
url: http://localhost:8080/nifi-api/resources
method: Get
register: nifi_resources
- name: Initiate the template
vars:
template_id: "{{ nifi_resources.json | to_json | from_json | json_query(query) | first}}"
uri:
url: http://localhost:8080/nifi-api/process-groups/root/template-instance
method: POST
body:
"originX": 2.0
"originY": 3.0
"templateId": "{{template_id.split('/')[2]}}"
status_code: 201
body_format: json
register: pipeline_info
- name: Set pipeline id property value
set_stats:
data:
id: "{{ pipeline_info.json.flow.processGroups[0].id }}"
---
- hosts: all
tasks:
- name: Get process group info
uri:
url: "http://localhost:8080/nifi-api/process-groups/{{pipeline_id}}"
method: GET
register: group_info
- name: Delete the pipeline
uri:
url: "http://localhost:8080/nifi-api/process-groups/{{pipeline_id}}?version={{group_info.json.revision.version}}&clientId={{group_info.json.revision.clientId }}"
method: DELETE
body_format: form-urlencoded
---
- hosts: all
tasks:
- name: Start the pipeline
uri:
url: "http://localhost:8080/nifi-api/flow/process-groups/{{pipeline_id}}"
method: PUT
body:
"id": "{{pipeline_id}}"
"state": "RUNNING"
status: 201
body_format: json
---
- hosts: all
tasks:
- name: Stop the pipeline
uri:
url: "http://localhost:8080/nifi-api/flow/process-groups/{{pipeline_id}}"
method: PUT
body:
"id": "{{pipeline_id}}"
"state": "STOPPED"
status: 201
body_format: json
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment