S
S
s_pyanov2021-05-25 04:02:08
Ansible
s_pyanov, 2021-05-25 04:02:08

How to change the value of variables in Ansible during the execution of tasks?

Good day to all.
Task: declare a variable at the beginning of the playbook and change its value as it is executed, example

---
- name: all hosts release
  hosts: all
  vars:
    release: none

  tasks:
    - debug:
        msg: "current release = {{ release }}"

    - name: присвоить переменной значение из файла или из другой переменной
      что_здесь_должно_быть: release = {{lookup('file','/env/service_account_checker/prod/version')}}  <- это не работает

    - debug:
        msg: "new release = {{ release }}"


Conceptually, I don’t understand how to assign a value to variables during the execution of tasks?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2021-05-25
@opium

Why does this sound so stupid?
You would lose its main advantage in the form of idempotency and in general your task is clearly not for the ansible and you have little understanding of what you are doing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question