Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
aa8ae850
Commit
aa8ae850
authored
Apr 26, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add playbook example for first_available_file
parent
38049101
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
examples/playbooks/selective_file_sources.yml
+28
-0
lib/ansible/runner.py
+1
-0
No files found.
examples/playbooks/selective_file_sources.yml
0 → 100644
View file @
aa8ae850
---
# this is an example of how to template a file over using some variables derived
# from the system. For instance, if you wanted to have different configuration
# templates by OS version, this is a neat way to do it. Any Ansible facts, facter facts,
# or ohai facts could be used to do this.
-
hosts
:
all
tasks
:
-
name
:
template a config file
action
:
template dest=/etc/imaginary_file.conf
first_available_file
:
# first see if we have a file for this specific host
-
/srv/whatever/{{ ansible_hostname }}.conf
# next try to load something like CentOS6.2.conf
-
/srv/whatever/{{ ansible_distribution }}{{ ansible_distribution_version }}.conf
# next see if there's a CentOS.conf
-
/srv/whatever/{{ ansible_distribution }}.conf
# finally give up and just use something generic
-
/srv/whatever/default
lib/ansible/runner.py
View file @
aa8ae850
...
...
@@ -391,6 +391,7 @@ class Runner(object):
# apply templating to source argument
inject
=
self
.
setup_cache
.
get
(
conn
.
host
,{})
# FIXME: break duplicate code up into subfunction
# if we have first_available_file in our vars
# look up the files and use the first one we find as src
if
'first_available_file'
in
self
.
module_vars
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment