Add creation of /etc/ansible hosts during install.#18
Closed
geomacy wants to merge 1 commit intoapache:masterfrom
Closed
Add creation of /etc/ansible hosts during install.#18geomacy wants to merge 1 commit intoapache:masterfrom
geomacy wants to merge 1 commit intoapache:masterfrom
Conversation
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
Contributor
Author
|
Needs more work - sudo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.