adding additional environment variables for gcp_compute + gcp modules

This commit is contained in:
Alex Stephen 2019-06-13 10:02:00 -07:00
parent 41b0367627
commit cb60f12b6b
5 changed files with 39 additions and 3 deletions

View File

@ -39,6 +39,20 @@ def gce(cred, env, private_data_dir):
f.close()
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR)
env['GCE_CREDENTIALS_FILE_PATH'] = path
handle, path = tempfile.mkstemp(dir=private_data_dir)
f = os.fdopen(handle, 'w')
json.dump(json_cred, f, indent=2)
f.close()
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR)
env['GCP_SERVICE_ACCOUNT_FILE'] = path
# Handle env variables for new module types.
# This includes gcp_compute inventory plugin and
# all new gcp_* modules.
env['GCP_AUTH_KIND'] = 'serviceaccount'
env['GCP_PROJECT'] = project
env['GCP_ENV_TYPE'] = 'tower'
return path

View File

@ -1,4 +1,8 @@
{
"ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never",
"GCE_CREDENTIALS_FILE_PATH": "{{ file_reference }}"
}
"GCE_CREDENTIALS_FILE_PATH": "{{ file_reference }}",
"GCP_AUTH_KIND": "serviceaccount",
"GCP_PROJECT": "fooo",
"GCP_ENV_TYPE": "tower",
"GCP_SERVICE_ACCOUNT_FILE": "{{ file_reference }}"
}

View File

@ -0,0 +1,7 @@
{
"type": "service_account",
"private_key": "{{private_key}}",
"client_email": "fooo",
"project_id": "fooo",
"token_uri": "https://oauth2.googleapis.com/token"
}

View File

@ -1,8 +1,12 @@
{
"GCE_EMAIL": "fooo",
"GCE_PROJECT": "fooo",
"GCP_PROJECT": "fooo",
"GCP_ENV_TYPE": "tower",
"GCP_AUTH_KIND": "serviceaccount",
"GCE_CREDENTIALS_FILE_PATH": "{{ file_reference }}",
"GCP_SERVICE_ACCOUNT_FILE": "{{ file_reference }}",
"GCE_ZONE": "us-east4-a,us-west1-b",
"GCE_INI_PATH": "{{ file_reference }}",
"ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never"
}
}

View File

@ -0,0 +1,7 @@
{
"type": "service_account",
"private_key": "{{private_key}}",
"client_email": "fooo",
"project_id": "fooo",
"token_uri": "https://oauth2.googleapis.com/token"
}