Skip to content
Permalink
Browse files
Update YAML example to newer syntax
Does 2 things:
- update `serviceType` to `type`
- update `start.latch` to `latch.start`
  • Loading branch information
tbouron committed Nov 9, 2017
1 parent ba01df1 commit e9cec2c23fe5b27eccb4ff060330b7615d4e30f0
Showing 1 changed file with 78 additions and 76 deletions.
@@ -126,86 +126,88 @@ There is no specific configuration in AnsibleEntity for Ansible [Roles](http://d
AnsibleEntity might require. The second child uses `attributeWhenReady` to block until the first is ready, before
starting the AnsibleEntity to apply the desired playbook.


name: multi
location:
red1
services:
- serviceType: brooklyn.entity.basic.SameServerEntity
name: Entities
brooklyn.children:

- serviceType: org.apache.brooklyn.entity.cm.ansible.AnsibleEntity
id: bootstrap
service.name: crond
playbook: bootstrap
playbook.yaml: |
---
- hosts: localhost
tasks:
- shell: printf "[tomcat-servers]\nlocalhost ansible_connection=local\n" >> /etc/ansible/hosts
- file: path=/etc/ansible/playbooks state=directory mode=0755
- get_url: url=https://github.com/ansible/ansible-examples/archive/master.zip dest=/tmp/master.zip mode=0440
- command: unzip -o -d /etc/ansible/playbooks /tmp/master.zip

- serviceType: org.apache.brooklyn.entity.stock.BasicApplication
latch.start: $brooklyn:entity("bootstrap").attributeWhenReady("service.isUp")
brooklyn.children:
- type: org.apache.brooklyn.entity.cm.ansible.AnsibleEntity
name: test
service.name: tomcat
playbook: tomcat
playbook.yaml: |
---
- hosts: localhost
- include: /etc/ansible/playbooks/ansible-examples-master/tomcat-standalone/site.yml
vars:
http_port: 8080
https_port: 8443
admin_username: admin
admin_password: secret
```yaml
name: multi
location:
red1
services:
- type: brooklyn.entity.basic.SameServerEntity
name: Entities
brooklyn.children:
- type: org.apache.brooklyn.entity.cm.ansible.AnsibleEntity
id: bootstrap
service.name: crond
playbook: bootstrap
playbook.yaml: |
---
- hosts: localhost
tasks:
- shell: printf "[tomcat-servers]\nlocalhost ansible_connection=local\n" >> /etc/ansible/hosts
- file: path=/etc/ansible/playbooks state=directory mode=0755
- get_url: url=https://github.com/ansible/ansible-examples/archive/master.zip dest=/tmp/master.zip mode=0440
- command: unzip -o -d /etc/ansible/playbooks /tmp/master.zip
- type: org.apache.brooklyn.entity.stock.BasicApplication
latch.start: $brooklyn:entity("bootstrap").attributeWhenReady("service.isUp")
brooklyn.children:
- type: org.apache.brooklyn.entity.cm.ansible.AnsibleEntity
name: test
service.name: tomcat
playbook: tomcat
playbook.yaml: |
---
- hosts: localhost
- include: /etc/ansible/playbooks/ansible-examples-master/tomcat-standalone/site.yml
vars:
http_port: 8080
https_port: 8443
admin_username: admin
admin_password: secret
```


An alternative to the above is to use Ansible itself to do the waiting, as in the variant below, which uses AnsibleEntity
itself in the first SameServerEntity child, to install the required material. In the second child, which is simply an
AnsibleEntity rather than a BasicApplication, Ansible's `wait_for` operation is used as the first step in the playbook,
to block the remaining steps in its playbook until the first is complete.

name: multi
location:
red1
services:
- serviceType: brooklyn.entity.basic.SameServerEntity
name: Entities
brooklyn.children:

- serviceType: org.apache.brooklyn.entity.cm.ansible.AnsibleEntity
id: bootstrap
service.name: crond
playbook: bootstrap
playbook.yaml: |
---
- hosts: localhost
tasks:
- command: rm -f /tmp/bootstrap.done
- shell: printf "[tomcat-servers]\nlocalhost ansible_connection=local\n" >> /etc/ansible/hosts
- file: path=/etc/ansible/playbooks state=directory mode=0755
- get_url: url=https://github.com/ansible/ansible-examples/archive/master.zip dest=/tmp/master.zip mode=0440
- command: unzip -o -d /etc/ansible/playbooks /tmp/master.zip
- file: path=/tmp/bootstrap.done state=touch

- serviceType: org.apache.brooklyn.entity.cm.ansible.AnsibleEntity
name: test
service.name: tomcat
playbook: tomcat
playbook.yaml: |
---
- tasks:
- wait_for: path=/tmp/bootstrap.done
include: /etc/ansible/playbooks/ansible-examples-master/tomcat-standalone/site.yml
vars:
http_port: 8080
https_port: 8443
admin_username: admin
admin_password: secret

```yaml
name: multi
location:
red1
services:
- type: brooklyn.entity.basic.SameServerEntity
name: Entities
brooklyn.children:
- type: org.apache.brooklyn.entity.cm.ansible.AnsibleEntity
id: bootstrap
service.name: crond
playbook: bootstrap
playbook.yaml: |
---
- hosts: localhost
tasks:
- command: rm -f /tmp/bootstrap.done
- shell: printf "[tomcat-servers]\nlocalhost ansible_connection=local\n" >> /etc/ansible/hosts
- file: path=/etc/ansible/playbooks state=directory mode=0755
- get_url: url=https://github.com/ansible/ansible-examples/archive/master.zip dest=/tmp/master.zip mode=0440
- command: unzip -o -d /etc/ansible/playbooks /tmp/master.zip
- file: path=/tmp/bootstrap.done state=touch
- type: org.apache.brooklyn.entity.cm.ansible.AnsibleEntity
name: test
service.name: tomcat
playbook: tomcat
playbook.yaml: |
---
- tasks:
- wait_for: path=/tmp/bootstrap.done
include: /etc/ansible/playbooks/ansible-examples-master/tomcat-standalone/site.yml
vars:
http_port: 8080
https_port: 8443
admin_username: admin
admin_password: secret
```

0 comments on commit e9cec2c

Please sign in to comment.