Hi Vladimir,

On Wed, Oct 4, 2023 at 5:38 PM Vladimir Botka <vbo...@gmail.com> wrote:

> > $ cat roles/nftables/defaults/main.yaml
> > forward_policy: drop
> >
> > $ cat roles/router/vars/main.yaml
> > forward_policy: accept
> >
> > I don't know how to override the variable in the nftables role from
> within
> > the router role.
>
> Is it possible to minimize the example?
>
> shell> tree .
> .
> ├── hosts
> ├── pb.yml
> └── roles
>     ├── nftables
>     │   ├── defaults
>     │   │   └── main.yml
>     │   └── tasks
>     │       └── main.yml
>     └── router
>         ├── tasks
>         │   └── main.yml
>         └── vars
>             └── main.yml
>
> shell> cat roles/nftables/defaults/main.yml
> forward_policy: drop
> shell> cat roles/nftables/tasks/main.yml
> - debug:
>     var: forward_policy
>
> shell> cat roles/router/vars/main.yml
> forward_policy: accept
> shell> cat roles/router/tasks/main.yml
> - debug:
>     var: forward_policy
>
> shell> cat hosts
> [router]
> zed
> shell> cat pb.yml
> - hosts: all
>   roles:
>     - nftables
>
> - hosts: router
>   roles:
>     - router
>
> Running the playbook gives
>
> shell> ansible-playbook pb.yml
>
> PLAY [all] *****************************
>
> TASK [nftables : debug] ****************
> ok: [zed] =>
>   forward_policy: drop
>

I would like forward_policy to be "accept" for the nftables role - since I
want the "router" role to affect how a j2 template gets set in the
"nftables" role.


>
> PLAY [router] **************************
>
> TASK [router : debug] ******************
> ok: [zed] =>
>   forward_policy: accept
>

So, I'd like to be able to modify a variable in one role from a different
role.

Or perhaps have a global variable that can bet set to a default value in
the role "nftables", but overridden in the role "router".

Thanks for the help!

-m

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAOLfK3UCmzU-B3Fuegc%2B3VB23g4UCo5hPq36uO9dx5UUqbPwLA%40mail.gmail.com.

Reply via email to