Created
June 6, 2018 23:50
-
-
Save sunapi386/e4dd68e305ec8352b37ccc95c6f5cd0e to your computer and use it in GitHub Desktop.
Ansible: if env var is not set prompt for value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - hosts: localhost | |
| tasks: | |
| - pause: | |
| prompt: "What is the GitLab registration token? " | |
| when: ( lookup('env','GITLAB_REGISTRATION_TOKEN') == "" ) | |
| register: reg_token | |
| no_log: true | |
| - set_fact: | |
| gitlab_registration_token: "{{ reg_token['user_input'] }}" | |
| when: ( lookup('env','GITLAB_REGISTRATION_TOKEN') == "" ) | |
| - set_fact: | |
| gitlab_registration_token: "{{ lookup('env','GITLAB_REGISTRATION_TOKEN') }}" | |
| when: ( lookup('env','GITLAB_REGISTRATION_TOKEN') != "" ) | |
| - debug: | |
| msg: "System {{ inventory_hostname }} has reg token {{ gitlab_registration_token }}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment