2

Is there a way to know if I'm launching a playbook from AWX or from the command line?

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Costales
  • 2,799
  • 1
  • 17
  • 21

1 Answers1

3

According Ansible Tower documentation Launch a Job Template

Tower automatically adds the following variables to the job environment: ...

  • tower_job_launch_type: The description to indicate how the job was started:

    • manual: Job was started manually by a user.

In other words, if specific variables are not set the job was not triggered from Ansible Tower (automatically).

A short example: assert – Asserts given expressions are true together with Providing default values can be used to

  - name: Check if job was triggered manually or automatically
    assert:
      that:
        - "'manual' not in tower_job_launch_type | default('manual')"
      fail_msg: "Job was triggered manually in Ansible Tower or via Ansible Engine!"
      quiet: true
U880D
  • 8,601
  • 6
  • 24
  • 40