-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaws-sa-bb-pipeline-setup.yml
63 lines (57 loc) · 2.07 KB
/
aws-sa-bb-pipeline-setup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
- name: "Setup BB Pipeline variables"
hosts: localhost
gather_facts: true
pre_tasks:
- name: BLock for pre_tasks
block:
- name: Test AWS_REGION
shell: "[[ -n $AWS_REGION ]]"
register: region
failed_when: false
changed_when: false
check_mode: no
- name: Test AWS_SECRET_ACCESS_KEY
shell: "[[ -n $AWS_SECRET_ACCESS_KEY ]]"
register: secret
failed_when: false
changed_when: false
check_mode: no
- name: Test AWS_ACCESS_KEY_ID
shell: "[[ -n $AWS_ACCESS_KEY_ID ]]"
register: key
failed_when: false
changed_when: false
check_mode: no
- name: Test if config file exists
stat:
path: "{{ config_file }}"
register: configfile
failed_when: false
changed_when: false
check_mode: no
- name: Do assertions on configfile and AWS credential envvars
assert:
that:
- "config_file is defined"
- "key.rc == 0"
- "secret.rc == 0"
- "region.rc == 0"
- "configfile.stat.exists"
- name: Set global facts
block:
- name: Convert organization name to CamelCase
set_fact:
cfn_org_name: "{{ organization.name | title }}"
cfn_tooling_name_prefix: "{{ tooling_account.name | default('NA') | replace('-', ' ') | replace('.', ' ') | title | replace(' ', '') }}"
tooling_name_prefix_env: "{{ tooling_account.name | default('NA') | replace('-', '') | replace('.', '') }}-{{ tooling_account.environment | default('prd') }}"
tags: [ 'always' ]
vars_files:
- "{{ config_file }}"
vars:
- org: "{{ organization.name | default('Unknown') }}"
- subaccount_limit: "{{ subaccount | default('all') }}"
- config_basedir: "{{ config_file | dirname }}"
tasks:
- name: BB ServiceAccount Variables
import_tasks: ansible-includes/aws-serviceaccounts-bb-repo-variables.yml