DEV Community

rndmh3ro
rndmh3ro

Posted on • Originally published at zufallsheld.de on

TIL that you can pass variables to Ansible’s import_playbook module

Using Ansible’s import_playbook module I was always under the impression that the module accepts no parameters and boldly stated so! However another commentor helpfully pointed out that I was wrong.

Here’s an example. The first playbook (importer_playbook.yml):

- import_playbook: imported-playbook.yml
  vars:
    foo: hunter2

Enter fullscreen mode Exit fullscreen mode

… simply imports a second playbook (imported_playbook.yml):

- hosts: localhost
  tasks:
  - debug:
      var: foo

Enter fullscreen mode Exit fullscreen mode

Running the importer-playbook results in this:

> ansible-playbook importer-playbook.yml
PLAY [localhost] 
********************************************
TASK [debug] 
********************************************
ok: [localhost] => {
    "foo": "hunter2"
}

PLAY RECAP 
********************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

Enter fullscreen mode Exit fullscreen mode

It’s even stated in the documentation as an example. However I did not scroll this far down. :(

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more