Hi Group,
I am trying to add some basic facts to a system but nothing seems to work.
My goal is to add a simple fact like the type of the server and the main
application running on it to be set
Type of server can be webserver (apache/tomcat)/ database server
(mysql/postgress .. etc)
And I would like to do this from the commandline with -e at initial
deployment of a server.
My main.yml looks like this
__________________________________________________________________________
---
# Task to set facts on system, based on commandline variables
- name: Set system facts
action: set_fact system_type={{system_type}}
action: set_fact main_app={{main_app}}
_________________________________________________________________________
and the result =
TASK: [system-config | Set system facts]
**************************************
ok: [my-targeted-machine]
I tried several forms of code like suggested in
the http://docs.ansible.com/set_fact_module.html page
____________________________________________________________________________
---
# Task to set facts on system, based on commandline variables
- name: Set system facts
set_fact: system_type="{{system_type}}" main_app="{{main_app}}"
____________________________________________________________________________
Has the same result
ok: [my-targeted-machine]
Or
____________________________________________________________________________
---
# Task to set facts on system, based on commandline variables
- name: Set system facts
- set_fact: system_type="{{system_type}}" main_app="{{main_app}}"
____________________________________________________________________________
Has this result : ERROR: 'action' or 'local_action' attribute missing in
task "Set system facts"
And when removing the -name: Set system facts line I can see my variables
are used from the commandline :-)
$ ansible-playbook -i 'mytargeted-machine,' all.yml --extra-vars
'{"system_type":"webservert","main_app":"apache2"}'
TASK: [system-config | set_fact system_type="webservert"
main_app="apache2"] ***
ok: [my-targeted-machine]
So what would be the best approach to set a fact ??
.
Ultimate goal: use fact caching and targeting machines with specific facts !
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/96dc963b-f803-4151-90a3-5f92ff818712%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.