<commit_before>tosca_definitions_version: cloudify_dsl_1_0

imports:
  - http://www.getcloudify.org/spec/cloudify/3.1/types.yaml
  - http://www.getcloudify.org/spec/openstack-plugin/1.1/plugin.yaml

plugins:
  cloudify-ansible-plugin:
    executor: central_deployment_agent
    source: https://github.com/earthmant/cloudify-ansible-plugin/archive/newtask.zip

inputs:

  image_name:
    type: string
  flavor_name:
    type: string
  test_group_name:
    type: string
  test_inventory_name:
    type: string
  playbook_file:
    type: string
  agent_key_path:
    type: string

node_templates:

  ansible_configuration:
    type: cloudify.nodes.ApplicationModule
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: cloudify-ansible-plugin.ansible_plugin.configure.create
        configure:
          implementation: cloudify-ansible-plugin.ansible_plugin.configure.validate

  webserver_security_group:
    type: cloudify.openstack.nodes.SecurityGroup
    properties:
      resource_id: webserver-secgroup
      security_group:
        description: Security group for webservers
      rules:
        - port: 0
          remote_ip_prefix: 0.0.0.0/0

  virtual_ip:
    type: cloudify.openstack.nodes.FloatingIP

  new_host:
    type: cloudify.openstack.nodes.Server
    properties:
      install_agent: false
      server:
        image_name: { get_input: image_name }
        flavor_name: { get_input: flavor_name }
    relationships:
      - type: cloudify.openstack.server_connected_to_floating_ip
        target: virtual_ip
      - type: cloudify.openstack.server_connected_to_security_group
        target: webserver_security_group

  add_host:
    type: cloudify.ansible.host
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: cloudify-ansible-plugin.ansible_plugin.tasks.add_host
          inputs:
            host: { get_attribute : [ add_host, address ] }
            group: { get_input : test_group_name }
            inventory: { get_input : test_inventory_name }
    relationships:
      - type: cloudify.relationships.depends_on
        target: virtual_ip

  apache_playbook:
    type: cloudify.ansible.playbook
    interfaces:
      cloudify.interfaces.lifecycle:
        start:
          implementation: cloudify-ansible-plugin.ansible_plugin.tasks.run_playbook
          inputs:
            inventory: { get_input : test_inventory_name }
            local_file: { get_input : playbook_file } # playbook_url or local_file to a file in the local directory
            agent_key: { get_input : agent_key_path }
    relationships:
      - type: cloudify.relationships.depends_on
        target: ansible_configuration
      - type: cloudify.relationships.depends_on
        target: add_host

node_types:

  cloudify.ansible.host:
    derived_from: cloudify.nodes.ApplicationModule
    interfaces:
      cloudify.interfaces.lifecycle:
        configure:
          implementation: cloudify-ansible-plugin.ansible_plugin.tasks.add_host
          inputs:
            host:
              default: ''
            group:
              default: ''
            inventory:
              default: ''

  cloudify.ansible.playbook:
    derived_from: cloudify.nodes.ApplicationModule
    interfaces:
      cloudify.interfaces.lifecycle:
        start:
          implementation: cloudify-ansible-plugin.ansible_plugin.tasks.run_playbook
          inputs:<commit_msg>changed blueprint to wait for host to be up<commit_after>tosca_definitions_version: cloudify_dsl_1_0

imports:
  - http://www.getcloudify.org/spec/cloudify/3.1/types.yaml
  - http://www.getcloudify.org/spec/openstack-plugin/1.1/plugin.yaml

plugins:
  cloudify-ansible-plugin:
    executor: central_deployment_agent
    source: https://github.com/earthmant/cloudify-ansible-plugin/archive/newtask.zip

inputs:

  image_name:
    type: string
  flavor_name:
    type: string
  test_group_name:
    type: string
  test_inventory_name:
    type: string
  playbook_file:
    type: string
  agent_key_path:
    type: string

node_templates:

  ansible_configuration:
    type: cloudify.nodes.ApplicationModule
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: cloudify-ansible-plugin.ansible_plugin.configure.create
        configure:
          implementation: cloudify-ansible-plugin.ansible_plugin.configure.validate

  webserver_security_group:
    type: cloudify.openstack.nodes.SecurityGroup
    properties:
      resource_id: webserver-secgroup
      security_group:
        description: Security group for webservers
      rules:
        - port: 0
          remote_ip_prefix: 0.0.0.0/0

  virtual_ip:
    type: cloudify.openstack.nodes.FloatingIP

  new_host:
    type: cloudify.openstack.nodes.Server
    properties:
      install_agent: false
      server:
        image_name: { get_input: image_name }
        flavor_name: { get_input: flavor_name }
    relationships:
      - type: cloudify.openstack.server_connected_to_floating_ip
        target: virtual_ip
      - type: cloudify.openstack.server_connected_to_security_group
        target: webserver_security_group

  add_host:
    type: cloudify.ansible.host
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: cloudify-ansible-plugin.ansible_plugin.tasks.add_host
          inputs:
            host: { get_attribute : [ add_host, address ] }
            group: { get_input : test_group_name }
            inventory: { get_input : test_inventory_name }
    relationships:
      - type: cloudify.relationships.depends_on
        target: virtual_ip

  apache_playbook:
    type: cloudify.ansible.playbook
    interfaces:
      cloudify.interfaces.lifecycle:
        start:
          implementation: cloudify-ansible-plugin.ansible_plugin.tasks.run_playbook
          inputs:
            inventory: { get_input : test_inventory_name }
            local_file: { get_input : playbook_file } # playbook_url or local_file to a file in the local directory
            agent_key: { get_input : agent_key_path }
    relationships:
      - type: cloudify.relationships.depends_on
        target: ansible_configuration
      - type: cloudify.relationships.depends_on
        target: new_host

node_types:

  cloudify.ansible.host:
    derived_from: cloudify.nodes.ApplicationModule
    interfaces:
      cloudify.interfaces.lifecycle:
        configure:
          implementation: cloudify-ansible-plugin.ansible_plugin.tasks.add_host
          inputs:
            host:
              default: ''
            group:
              default: ''
            inventory:
              default: ''

  cloudify.ansible.playbook:
    derived_from: cloudify.nodes.ApplicationModule
    interfaces:
      cloudify.interfaces.lifecycle:
        start:
          implementation: cloudify-ansible-plugin.ansible_plugin.tasks.run_playbook
          inputs:
{'fraction_non_alphanumeric': 0.07481224725592144, 'fraction_numerical': 0.0034662045060658577, 'mean_word_length': 2.64281956864808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6262045', 'n_tokens_mistral': 2080, 'n_tokens_neox': 2067, 'n_words': 347}