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
35e61d8f
Commit
35e61d8f
authored
Apr 22, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2688 from dagwieers/module-global
New module 'set_fact' to define host facts
parents
2fb43072
b13beb36
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
0 deletions
+91
-0
lib/ansible/runner/action_plugins/set_fact.py
+37
-0
library/set_fact
+54
-0
No files found.
lib/ansible/runner/action_plugins/set_fact.py
0 → 100644
View file @
35e61d8f
# Copyright 2013 Dag Wieers <dag@wieers.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from
ansible
import
utils
from
ansible.runner.return_data
import
ReturnData
class
ActionModule
(
object
):
NEEDS_TMPPATH
=
False
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
def
run
(
self
,
conn
,
tmp
,
module_name
,
module_args
,
inject
,
complex_args
=
None
,
**
kwargs
):
''' handler for running operations on master '''
# load up options
options
=
{}
if
complex_args
:
options
.
update
(
complex_args
)
options
.
update
(
utils
.
parse_kv
(
module_args
))
return
ReturnData
(
conn
=
conn
,
result
=
dict
(
ansible_facts
=
options
))
library/set_fact
0 → 100644
View file @
35e61d8f
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2013 Dag Wieers <dag@wieers.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
DOCUMENTATION
=
'''
---
author: Dag Wieers
module: set_fact
short_description: Set host facts from a task
description:
- This module allows you to set host facts from a task. This can be
useful for setting facts conditionally or allows to 'export' play
variables set by 'vars:' or 'vars_files:' to the playbook scope .
- In comparison to variables defined in the playbook, global variables
can be set conditionally (like any module) and are available in other
plays.
options:
key_value:
description:
- The C(set_fact) module takes key=value pairs as variables to set
in the playbook scope. Or alternatively, accepts complex arguments
using the C(args:) statement.
required: true
default: null
version_added: "1.2"
examples:
- description: "Example setting host facts using key=value pairs"
code: |
action: set_fact fact="something" global_fact="${local_var}"'
- description: "Example setting host facts using complex arguments"
code: |
action: set_fact
args:
fact: something
global_fact: ${local_var}
notes:
- You can set play variables using the C(set_var) module.
'''
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