So I am having an issue about not knowing what the best thing to do is. Here’s what I am trying to accomplish…
I have the following sanitized tasks:
- name: Set authorized key ( prod)
authorized_key:
user: ansible
state: present
key: “{{ lookup(‘file’, 'ssh public key file) }}”
key_options: ‘from=“Prod control node IP”’
- name: Set authorized key ( test)
authorized_key:
user: ansible
state: present
key: “{{ lookup(‘file’, 'ssh public key file) }}”
key_options: ‘from=“testlab control node IP”’
The key option specifies that only the ansible control node can use ssh keys to the ansible account.
So is there a way to say execute the prod task unless a “test” tag is passed? At the same time, I want to do the opposite with the test task, and say only execute if the “test” tag is passed. (I know how to do this second part),
My other option, would be to just set a variable, and I know I can do it that way, but wasn’t sure if I could do the same thing with a tag.
–John