-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
124 lines (92 loc) · 4.3 KB
/
cloudbuild.yaml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# cloudbuild.yaml
# In this directory, run the following command to build this builder.
# $ gcloud builds submit . --config=cloudbuild.yaml
# See docs at https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli
steps:
# Step 1: Install Terraform
#- name: 'hashicorp/terraform:latest'
# entrypoint: 'sh'
# args: ['-c', 'curl -Lo terraform.zip https://releases.hashicorp.com/terraform/$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M .current_version)/terraform_$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M .current_version)_linux_amd64.zip && unzip terraform.zip && chmod +x terraform && mv terraform /usr/local/bin']
# Step 2: Authenticate with Google Cloud
- name: 'gcr.io/cloud-builders/gcloud'
args: ['components', 'install', 'kubectl']
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
apt-get update && apt-get install -y ansible && apt-get install -y python3.8
gcloud source repos clone ansible --project=test-ground-403314
cd ansible
gcloud secrets versions access latest --project=test-ground-403314 --secret=sshcred > oslogin
gcloud secrets versions access latest --project=test-ground-403314 --secret=gitmanjson > sc.json
chmod 400 oslogin
chmod 400 sc.json
gcloud auth activate-service-account [email protected] --key-file=sc.json
update-ca-certificates --fresh
export SSL_CERT_DIR=/etc/ssl/certs
chmod og-rw /builder/home/.netrc
apt-get --assume-yes install python3-pip
pip install google-auth
ansible-galaxy collection install google.cloud
ansible-inventory --list -i ansible.gcp.yml > allinv.json
python3 inv.py
tr < inventory.csv -d '\000' > inventory2.csv
tr < disks.csv -d '\000' > disks2.csv
bq load --source_format=CSV --autodetect --replace inventory.inventory inventory2.csv
bq load --source_format=CSV --autodetect --replace inventory.disks disks2.csv
### ansible-playbook runupdates.yaml -i hosts --private-key=oslogin -l preprodgroup1:devbox
#- name: 'gcr.io/cloud-builders/gcloud'
# entrypoint: 'bash'
# args:
# - '-c'
# - |
# # Clone your Ansible playbook repository
# gcloud source repos clone ansible --project=mofo-proj
#- name: 'gcr.io/cloud-builders/gcloud'
# entrypoint: 'bash'
# args:
# - '-c'
# - |
# # Change directory to your Ansible playbook directory
# cd ansible
#- name: 'gcr.io/cloud-builders/ansible'
# entrypoint: 'bash'
# args:
# - '-c'
# - |
# # Run your Ansible playbook
# ansible-playbook ./main.yml D ./keith -i hosts
#- name: 'ubuntu'
# entrypoint: 'bash'
# args:
# - '-c'
# - |
# cd ansible # Change to the directory containing your Ansible playbook
# apt-get update
# apt-get -y install ansible
# ansible-playbook main.yaml --private-key oslogin -i hosts
#- name: 'gcr.io/$PROJECT_ID/ansible'
# entrypoint: '/usr/bin/ansible-playbook'
# args: ['main.yaml', '--private-key', 'oslogin', '-i', 'hosts'] # '--private-key', 'ansible', , '-e', 'ansible_python_interpreter=python3', '-m', 'setup', '-a', 'filter=ansible_hostname']
#images:
#- 'gcr.io/$PROJECT_ID/ansible'
# Step 3: Run Terraform commands
#- name: 'hashicorp/terraform:latest'
# entrypoint: 'sh'
# args: ['-c', 'terraform init && terraform plan']
#- name: 'gcr.io/cloud-builders/wget'
# args: ["https://releases.hashicorp.com/packer/${_PACKER_VERSION}/packer_${_PACKER_VERSION}_linux_amd64.zip"]
#- name: 'gcr.io/cloud-builders/docker'
# args: ['build', '-t', 'gcr.io/$PROJECT_ID/packer:${_PACKER_VERSION}',
# '-t', 'gcr.io/$PROJECT_ID/packer',
# '--build-arg', 'PACKER_VERSION=${_PACKER_VERSION}',
# '--build-arg', 'PACKER_VERSION_SHA256SUM=${_PACKER_VERSION_SHA256SUM}',
# '.']
#substitutions:
#_PACKER_VERSION: 1.9.2
#_PACKER_VERSION_SHA256SUM: 34fe48d0d5f99670af15d8a3b581db7ce9d08093ce37240d7c7b996de7947275
#images:
# - 'gcr.io/$PROJECT_ID/packer:latest'
# - 'gcr.io/$PROJECT_ID/packer:${_PACKER_VERSION}'
#tags: ['cloud-builders-community']