On 08.08.2019 03:53, Veera wrote:
> Hi kai,
> 
> Thanks for the  inputs.
> 
> "for security reasons".   - I mean that we have disabled gather_facts for
> better  performance.  And we want other users to play the playbook with
> access to the same inventory .
> I am looking for a way to avoid them  running "ansible-playbook pb.yml -e
> myvar=all"    and to always  use "myvar=hostname."
> 
> is there a way to stop  a particular user to stop using " myvar=all" based
> on inventory  or other modes?

You could use this
  hosts: '{{ "" if myvar == "all" else myvar }}'

If myvar is all hosts becomes empty sting and that is not allowed and Ansible 
will fail.

But this is easily defeated but adding a comma at the end myvar=all,
To fix that you would need to use the search/regex[1] test and craft a 
appropriate regexp for this.


[1] 
https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#testing-strings


-- 
Kai Stian Olstad

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3b7b4ddb-e6e8-ab24-0350-6572eac487a3%40olstad.com.

Reply via email to