Skip to content

Instantly share code, notes, and snippets.

@sunapi386
Created June 6, 2018 23:50
Show Gist options
  • Select an option

  • Save sunapi386/e4dd68e305ec8352b37ccc95c6f5cd0e to your computer and use it in GitHub Desktop.

Select an option

Save sunapi386/e4dd68e305ec8352b37ccc95c6f5cd0e to your computer and use it in GitHub Desktop.
Ansible: if env var is not set prompt for value
---
- 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