On 01. sep. 2016 11:00, fanvalt wrote:
Hello,

I want to set variables with set_fact in a pre_tasks section.
This is working well, but it is 50 lines long and I want to have these
lines to be set in all my playbooks.

Is there a way to include a pre_tasks ? Here is what I would expect:

- include: <your.file>

https://docs.ansible.com/ansible/playbooks_roles.html#task-include-files-and-encouraging-reuse


  pre_tasks:
    - name: variables Instance 1 DV/QA
      set_fact:
        KARAFHTTPPORT: "210{{ Slice }}"
        KARAFSSHPORT: "211{{ Slice }}"
        KARAFRMIREGISTRYPORT: "212{{ Slice }}"
        KARAFRMISERVERPORT: "213{{ Slice }}"
      when: numint == '1' and ( EnvType == 'DV' or EnvType == 'QA')
...

I would like to copy these lines in a setting.yml file, I don't know where
it would be conventional, lets say in vars directory.

vars, settings, tasks... as long as you don't use any of the reserved directories you are good.

And then call it this way:
  pre_tasks:
       vars/setting.yml

  pre_tasks:
    - include: vars/settings.yml

--
Kai Stian Olstad

--
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/42989965-27a7-fe5e-63ce-a92c5a8d5571%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to