Persist the exposed variables as local facts

This commit is contained in:
Nick Janetakis
2014-07-01 20:21:26 -04:00
parent e711bf6d98
commit d1ffc74d78
5 changed files with 20 additions and 7 deletions

View File

@@ -51,9 +51,11 @@ rvm1_rvm_stable_version_number: 'https://raw.githubusercontent.com/wayneeseguin/
rvm1_rvm_force_upgrade_installer: false
```
## Exposed variables for use in other roles
## Facts
You will likely want to use various ruby related commands in other roles. This role exposes a number of popular paths and variables for easy access.
You will likely want to use various ruby related commands in other roles. This role exposes a number of popular paths and variables as persisted facts.
Since the values are saved to `/etc/ansible/facts.d/rvm1.fact` you do not need to run this role every time you invoke your play book to have access to the facts. They will be persisted between play book runs.
- `rvm1_default_ruby_version`
- The default ruby version that is selected

6
tasks/facts.yml Normal file
View File

@@ -0,0 +1,6 @@
---
- name: ensure /etc/ansible/facts.d is created
file: path='/etc/ansible/facts.d' state='directory'
- name: ensure facts are persisted in /etc/ansible/facts.d/rvm1.fact
template: src='etc/ansible/facts.d/rvm1.fact.j2' dest='/etc/ansible/facts.d/rvm1.fact'

View File

@@ -1,3 +1,4 @@
---
- include: 'facts.yml
- include: 'rvm.yml'
- include: 'rubies.yml'

View File

@@ -0,0 +1 @@
{{ rvm1_facts }}

View File

@@ -1,8 +1,11 @@
---
rvm1_default_ruby_version: '{{ rvm1_rubies | last if rvm1_rubies and rvm1_rubies is iterable else "" }}'
rvm1: '{{ rvm1_install_path }}/bin/rvm'
rvm1_default_wrappers: '{{ rvm1_install_path }}/wrappers/default'
rvm1_ruby: '{{ rvm1_default_wrappers }}/ruby'
rvm1_gem: '{{ rvm1_default_wrappers }}/gem'
rvm1_bundle: '{{ rvm1_default_wrappers }}/bundle'
rvm1_rake: '{{ rvm1_bundle }} exec {{ rvm1_default_wrappers }}/rake'
rvm1_facts: |
rvm1_default_ruby_version='{{ rvm1_rubies | last if rvm1_rubies and rvm1_rubies is iterable else "" }}'
rvm1='{{ rvm1_install_path }}/bin/rvm'
rvm1_default_wrappers= '{{ rvm1_default_wrappers }}'
rvm1_ruby='{{ rvm1_default_wrappers }}/ruby'
rvm1_gem='{{ rvm1_default_wrappers }}/gem'
rvm1_bundle='{{ rvm1_bundle }}'
rvm1_rake='{{ rvm1_bundle }} exec {{ rvm1_default_wrappers }}/rake'