GitHub user geomacy opened a pull request:
https://github.com/apache/brooklyn-library/pull/19
Add creation of /etc/ansible hosts during install.
This allows replacement of the command form
ansible-playbook -i \"localhost,\" -c local whatever
with
ansible-playbook whatever
and also supports the possibility that playbooks can modify the hosts file
e.g. by adding additional groups that included roles require.
For example the following playbook modifies the hosts to add a
tomcat-server group, in order to install an example ansible from the github
examples repo.
```yaml
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
start.latch:
$brooklyn:component("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
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/geomacy/brooklyn-library ansible-host-file
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/brooklyn-library/pull/19.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #19
----
commit cf65e18d1b775d3528c9ba05c1229d748a6807bd
Author: Geoff Macartney <[email protected]>
Date: 2016-03-11T17:25:25Z
Add creation of /etc/ansible hosts during install.
This allows replacement of the command form
ansible-playbook -i \"localhost,\" -c local whatever
with
ansible-playbook whatever
and also supports the possibility that playbooks can modify the hosts file
e.g. by adding additional groups that included roles require.
For example the following playbook modifies the hosts to add a
tomcat-server group, in order to install an example ansible from the github
examples repo.
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
start.latch:
$brooklyn:component("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
commit 7e97a26b9e79ab8e04c4052d4a2a5658f6f4d62d
Author: Geoff Macartney <[email protected]>
Date: 2016-03-11T22:35:36Z
Add sudo to setup of hosts file.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---