Skip to content

Commit 6a98cca

Browse files
authored
Merge pull request #43 from oracle-devrel/develop
Automation Toolkit Release v10.2
2 parents 12e772c + ff9da5d commit 6a98cca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1069
-886
lines changed

Dockerfile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ ARG USERNAME=cd3user
66
ARG USER_UID=1001
77
ARG USER_GID=$USER_UID
88

9-
109
RUN yum install sudo -y && groupadd --gid $USER_GID $USERNAME \
11-
&& useradd --uid $USER_UID --gid $USER_GID -d /$USERNAME -m $USERNAME \
12-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
13-
&& chmod 0440 /etc/sudoers.d/$USERNAME \
14-
&& mkdir /cd3user/tenancies/ && sudo chown -R $USERNAME:$USERNAME /cd3user/tenancies/
10+
&& useradd --uid $USER_UID --gid $USER_GID -d /$USERNAME -m $USERNAME \
11+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
12+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
13+
&& mkdir /cd3user/tenancies/ && sudo chown -R $USERNAME:$USERNAME /cd3user/tenancies/
1514

1615

1716
USER $USERNAME
1817
WORKDIR /cd3user/oci_tools/
1918
COPY . .
2019

2120
RUN sudo yum install -y oracle-softwarecollection-release-el7 \
22-
&& sudo chown -R $USER:$USER /cd3user/ \
23-
&& sudo chmod -R 777 /cd3user/
21+
&& sudo chown -R $USERNAME:$USERNAME /cd3user/
2422

2523

2624
WORKDIR /cd3user/
27-
RUN sed -i -e 's/\r$//' /cd3user/oci_tools/cd3_automation_toolkit/shell_script.sh \
28-
&& /cd3user/oci_tools/cd3_automation_toolkit/shell_script.sh \
29-
&& sudo chown -R cd3user:cd3user /cd3user/ && sudo yum clean all && sudo rm -rf /var/cache/yum /root/ocswork \
30-
&& sudo rm -rf /cd3user/oci_tools/Dockerfile && sudo rm -rf /cd3user/oci_tools/Readme.md \
31-
&& sudo rm -rf /cd3user/oci_tools/.git && sudo rm -rf /cd3user/oci_tools/.gitignore
25+
26+
RUN sudo sed -i -e 's/\r$//' /cd3user/oci_tools/cd3_automation_toolkit/shell_script.sh \
27+
&& bash /cd3user/oci_tools/cd3_automation_toolkit/shell_script.sh \
28+
&& sudo chown -R cd3user:cd3user /cd3user/ && sudo yum clean all && sudo rm -rf /var/cache/yum /root/ocswork \
29+
&& sudo rm -rf /cd3user/oci_tools/Dockerfile && sudo rm -rf /cd3user/oci_tools/Readme.md \
30+
&& sudo rm -rf /cd3user/oci_tools/.git && sudo rm -rf /cd3user/oci_tools/.gitignore && sudo chmod -R 740 /cd3user/
31+
32+
3233

3334

34-
CMD ["bash"]

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@
1515
7. MUST READ...
1616
- [Managing Network for Green Field Tenancies](/cd3_automation_toolkit/documentation/user_guide/NetworkingScenariosGF.md)
1717
- [Managing Network for Non Green Field Tenancies](/cd3_automation_toolkit/documentation/user_guide/NetworkingScenariosNGF.md)
18-
8. [Creating independent tfstate files for each resource](/cd3_automation_toolkit/documentation/user_guide/RestructuringOutDirectory.md)
18+
8. [Grouping of generated Terraform files](/cd3_automation_toolkit/documentation/user_guide/RestructuringOutDirectory.md)
1919
9. [Expected Behaviour Of Automation Toolkit](/cd3_automation_toolkit/documentation/user_guide/KnownBehaviour.md)
2020
10. [FAQs](/cd3_automation_toolkit/documentation/user_guide/FAQ.md)
21-
11. [Steps to Upgrade Your Toolkit](/cd3_automation_toolkit/documentation/user_guide/Upgrade_Toolkit.md)
22-
12. Learn More...
21+
11. [What's new in this release!!](https://github.com/oracle-devrel/cd3-automation-toolkit/releases/tag/v10.1)
22+
12. [Steps to Upgrade Your Toolkit](/cd3_automation_toolkit/documentation/user_guide/Upgrade_Toolkit.md)
23+
13. Learn More...
2324
- CD3 Excel Information
2425
- [Excel Templates](/cd3_automation_toolkit/documentation/user_guide/RunningAutomationToolkit.md#excel-sheet-templates)
2526
- [Toolkit Supported OCI Services](/cd3_automation_toolkit/documentation/user_guide/learn_more/CD3ExcelTabs.md)
2627
- [CD3 Validator Features](/cd3_automation_toolkit/documentation/user_guide/learn_more/SupportForCD3Validator.md)
2728
- [Additional CIS Compliance Features](/cd3_automation_toolkit/documentation/user_guide/learn_more/CISFeatures.md)
2829
- [OCI Resource Manager Upload](/cd3_automation_toolkit/documentation/user_guide/learn_more/ResourceManagerUpload.md)
2930
- [Support for Additional Attributes](/cd3_automation_toolkit/documentation/user_guide/learn_more/SupportforAdditionalAttributes.md)
30-
13. [Automation Toolkit Learning Videos](/cd3_automation_toolkit/documentation/user_guide/LearningVideos.md)
31+
14. [Automation Toolkit Learning Videos](/cd3_automation_toolkit/documentation/user_guide/LearningVideos.md)
32+
3133

3234
## Introduction
3335
CD3 stands for <b>C</b>loud <b>D</b>eployment <b>D</b>esign <b>D</b>eliverable.

cd3_automation_toolkit/Compute/create_terraform_instances.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,7 @@ def create_terraform_instances(inputfile, outdir, service_dir,prefix, config):
184184
NSGs = columnvalue.split(",")
185185
k = 0
186186
while k < len(NSGs):
187-
if "ocid" in NSGs[k].strip():
188-
nsg = "\"" + NSGs[k].strip() + "\""
189-
else:
190-
nsg = "\"" + commonTools.check_tf_variable(NSGs[k].strip()) + "\""
191-
187+
nsg = "\"" + NSGs[k].strip() + "\""
192188
nsg_str = nsg_str + str(nsg)
193189
if (k != len(NSGs) - 1):
194190
nsg_str = nsg_str + ","

cd3_automation_toolkit/Database/create_terraform_adb.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ def create_terraform_adb(inputfile, outdir, service_dir, prefix, config=DEFAULT_
135135
NSGs = columnvalue.split(",")
136136
k = 0
137137
while k < len(NSGs):
138-
if "ocid" in NSGs[k].strip():
139-
nsg = "\"" + NSGs[k].strip() + "\""
140-
else:
141-
nsg = "\"" + commonTools.check_tf_variable(NSGs[k].strip()) + "\""
138+
nsg = "\"" + NSGs[k].strip() + "\""
142139

143140
nsg_str = nsg_str + str(nsg)
144141
if (k != len(NSGs) - 1):

cd3_automation_toolkit/Database/create_terraform_dbsystems_vm_bm.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,12 @@ def create_terraform_dbsystems_vm_bm(inputfile, outdir, service_dir, prefix, con
196196
db_nsgs = str(columnvalue).strip().split(",")
197197
if len(db_nsgs) == 1:
198198
for nsg in db_nsgs:
199-
if "ocid" in nsg.strip():
200-
nsg_id = "\"" + nsg.strip() + "\""
201-
else:
202-
nsg_id = "\"" + commonTools.check_tf_variable(str(nsg).strip()) + "\""
199+
nsg_id = "\"" + nsg.strip() + "\""
203200

204201
elif len(db_nsgs) >= 2:
205202
c = 1
206203
for nsg in db_nsgs:
207-
if "ocid" in nsg.strip():
208-
data = "\"" + nsg.strip() + "\""
209-
else:
210-
data = "\"" + commonTools.check_tf_variable(str(nsg).strip()) + "\""
204+
data = "\"" + nsg.strip() + "\""
211205

212206
if c == len(db_nsgs):
213207
nsg_id = nsg_id + data
@@ -221,18 +215,12 @@ def create_terraform_dbsystems_vm_bm(inputfile, outdir, service_dir, prefix, con
221215
backup_nsgs = str(columnvalue).strip().split(",")
222216
if len(backup_nsgs) == 1:
223217
for nsgs in backup_nsgs:
224-
if "ocid" in nsgs.strip():
225-
backup_nsg_id = "\"" + nsgs.strip() + "\""
226-
else:
227-
backup_nsg_id = "\"" + commonTools.check_tf_variable(str(nsgs).strip()) + "\""
218+
backup_nsg_id = "\"" + nsgs.strip() + "\""
228219

229220
elif len(backup_nsgs) >= 2:
230221
c = 1
231222
for nsgs in backup_nsgs:
232-
if "ocid" in nsgs.strip():
233-
data = "\"" + nsgs.strip() + "\""
234-
else:
235-
data = "\"" + commonTools.check_tf_variable(str(nsgs).strip()) + "\""
223+
data = "\"" + nsgs.strip() + "\""
236224

237225
if c == len(backup_nsgs):
238226
backup_nsg_id = backup_nsg_id + data

cd3_automation_toolkit/Database/create_terraform_exa_vmclusters.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,12 @@ def create_terraform_exa_vmclusters(inputfile, outdir, service_dir, prefix, conf
189189
db_nsgs = str(columnvalue).strip().split(",")
190190
if len(db_nsgs) == 1:
191191
for nsg in db_nsgs:
192-
if "ocid" in nsg.strip():
193-
nsg_id = "\"" + nsg.strip() + "\""
194-
else:
195-
nsg_id = "\"" + commonTools.check_tf_variable(str(nsg).strip()) + "\""
192+
nsg_id = "\"" + nsg.strip() + "\""
196193

197194
elif len(db_nsgs) >= 2:
198195
c = 1
199196
for nsg in db_nsgs:
200-
if "ocid" in nsg.strip():
201-
data = "\"" + nsg.strip() + "\""
202-
else:
203-
data = "\"" + commonTools.check_tf_variable(str(nsg).strip()) + "\""
197+
data = "\"" + nsg.strip() + "\""
204198

205199
if c == len(db_nsgs):
206200
nsg_id = nsg_id + data
@@ -215,18 +209,12 @@ def create_terraform_exa_vmclusters(inputfile, outdir, service_dir, prefix, conf
215209
backup_nsgs = str(columnvalue).strip().split(",")
216210
if len(backup_nsgs) == 1:
217211
for nsgs in backup_nsgs:
218-
if "ocid" in nsgs.strip():
219-
backup_nsg_id = "\"" + nsgs.strip() + "\""
220-
else:
221-
backup_nsg_id = "\"" + commonTools.check_tf_variable(str(nsgs).strip()) + "\""
212+
backup_nsg_id = "\"" + nsgs.strip() + "\""
222213

223214
elif len(backup_nsgs) >= 2:
224215
c = 1
225216
for nsgs in backup_nsgs:
226-
if "ocid" in nsgs.strip():
227-
data = "\"" + nsgs.strip() + "\""
228-
else:
229-
data = "\"" + commonTools.check_tf_variable(str(nsgs).strip()) + "\""
217+
data = "\"" + nsgs.strip() + "\""
230218

231219
if c == len(backup_nsgs):
232220
backup_nsg_id = backup_nsg_id + data

cd3_automation_toolkit/Database/export_dbsystems_vm_bm_nonGreenField.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def print_dbsystem_vm_bm(region, db_system_vm_bm, count,db_home, database ,vnc_c
7575
elif col_header == 'Compartment Name':
7676
values_for_column[col_header].append(ntk_compartment_name)
7777
elif col_header == 'Subnet Name':
78-
values_for_column[col_header].append(commonTools.check_tf_variable(vcn_name + "_" + sub_name))
78+
values_for_column[col_header].append(vcn_name + "_" + sub_name)
7979
elif col_header == 'DB Admin Password':
8080
values_for_column[col_header].append('nullval')
8181
elif col_header == 'SSH Key Var Name':

cd3_automation_toolkit/DeveloperServices/OKE/create_terraform_oke.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,7 @@ def create_terraform_oke(inputfile, outdir, service_dir, prefix, config=DEFAULT_
317317
NSGs = columnvalue.split(",")
318318
k = 0
319319
while k < len(NSGs):
320-
if "ocid" in NSGs[k].strip():
321-
nsg = "\"" + NSGs[k].strip() + "\""
322-
else:
323-
nsg = "\"" + commonTools.check_tf_variable(NSGs[k].strip()) + "\""
320+
nsg = "\"" + NSGs[k].strip() + "\""
324321

325322
nsg_str = nsg_str + str(nsg)
326323
if (k != len(NSGs) - 1):
@@ -335,10 +332,7 @@ def create_terraform_oke(inputfile, outdir, service_dir, prefix, config=DEFAULT_
335332
NSGs = columnvalue.split(",")
336333
k = 0
337334
while k < len(NSGs):
338-
if "ocid" in NSGs[k].strip():
339-
nsg = "\"" + NSGs[k].strip() + "\""
340-
else:
341-
nsg = "\"" + commonTools.check_tf_variable(NSGs[k].strip()) + "\""
335+
nsg = "\"" + NSGs[k].strip() + "\""
342336

343337
nsg_str = nsg_str + str(nsg)
344338
if (k != len(NSGs) - 1):
@@ -353,10 +347,7 @@ def create_terraform_oke(inputfile, outdir, service_dir, prefix, config=DEFAULT_
353347
NSGs = columnvalue.split(",")
354348
k = 0
355349
while k < len(NSGs):
356-
if "ocid" in NSGs[k].strip():
357-
nsg = "\"" + NSGs[k].strip() + "\""
358-
else:
359-
nsg = "\"" + commonTools.check_tf_variable(NSGs[k].strip()) + "\""
350+
nsg = "\"" + NSGs[k].strip() + "\""
360351

361352
nsg_str = nsg_str + str(nsg)
362353
if (k != len(NSGs) - 1):

cd3_automation_toolkit/DeveloperServices/ResourceManager/create_resource_manager_stack.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import argparse
1111
import os
12+
from zipfile import ZipFile
1213
import shutil
1314
import time
1415
import csv
@@ -102,7 +103,6 @@ def create_resource_manager(outdir, outdir_struct,prefix,regions, config=DEFAULT
102103
ct = commonTools()
103104
ct.get_subscribedregions(configFileName)
104105
ct.get_network_compartment_ids(config['tenancy'],"root",configFileName)
105-
106106
x = datetime.datetime.now()
107107
date = x.strftime("%f").strip()
108108

@@ -246,7 +246,20 @@ def create_resource_manager(outdir, outdir_struct,prefix,regions, config=DEFAULT
246246
#Process files in region directory - single outdir
247247
if len(outdir_struct.items())==0:
248248
rm_name = prefix + "-" + region
249-
shutil.make_archive(rm_name, 'zip', rm_dir)
249+
#shutil.make_archive(rm_name, 'zip', rm_dir)
250+
zip_name = rm_name + ".zip"
251+
# Fix for make_archive huge zip file issue - Ulag
252+
file_paths = []
253+
for root, directories, files in os.walk(rm_dir):
254+
for filename in files:
255+
rel_dir = os.path.relpath(root, rm_dir)
256+
filepath = os.path.join(rel_dir, filename)
257+
file_paths.append(filepath)
258+
259+
with ZipFile(zip_name, 'w') as zipp:
260+
for file in file_paths:
261+
if zip_name not in file and 'terraform.tfstate' not in file:
262+
zipp.write(file)
250263

251264
if (region, rm_name) in rm_region_service_map.keys():
252265
try:
@@ -286,15 +299,16 @@ def create_resource_manager(outdir, outdir_struct,prefix,regions, config=DEFAULT
286299
rm_dir_zip = region_dir + '/' + prefix + '-' + region +'.zip'
287300
# Take a backup of zip file if it exists
288301
if os.path.exists(rm_dir_zip):
289-
shutil.copy(rm_dir_zip, rm_dir_zip + "_backup")
302+
shutil.move(rm_dir_zip, rm_dir_zip + "_backup")
290303

291-
base_name = prefix + "-" + region
292304
os.chdir("../")
293-
shutil.make_archive(base_name, 'zip', rm_dir)
305+
#shutil.make_archive(base_name, 'zip', rm_dir)
306+
shutil.move(rm_dir+"/"+zip_name,region_dir)
294307

295308
#Process service_dirs - separate outdir
296309
else:
297310
service_dir_processed = []
311+
298312
for service, service_dir in outdir_struct.items():
299313
svcs = dir_svc_map[service_dir]
300314
if(service_dir in service_dir_processed):
@@ -317,8 +331,24 @@ def create_resource_manager(outdir, outdir_struct,prefix,regions, config=DEFAULT
317331
f.close()
318332

319333
service_rm_name = prefix + "-" + region + "-" + service_dir
320-
shutil.make_archive(service_rm_name, 'zip', service_dir)
321-
334+
#shutil.make_archive(service_rm_name, 'zip', service_dir)
335+
336+
zip_name = service_rm_name + ".zip"
337+
# Fix for make_archive huge zip file issue - Ulag
338+
file_paths = []
339+
340+
for root, directories, files in os.walk(service_dir):
341+
for filename in files:
342+
rel_dir = os.path.relpath(root, service_dir)
343+
filepath = os.path.join(rel_dir, filename)
344+
file_paths.append(filepath)
345+
346+
with ZipFile(zip_name, 'w') as zipp:
347+
for file in file_paths:
348+
if zip_name not in file and 'terraform.tfstate' not in file:
349+
os.chdir(rm_dir + "/" + service_dir)
350+
zipp.write(file)
351+
os.chdir("../")
322352
if (region,service_rm_name) in rm_region_service_map.keys():
323353
try:
324354
service_rm_ocid = rm_region_service_map[(region,service_rm_name)]
@@ -361,7 +391,7 @@ def create_resource_manager(outdir, outdir_struct,prefix,regions, config=DEFAULT
361391
rm_dir_zip = region_dir + '/' + prefix + '-' + region + '-stacks.zip'
362392
# Take a backup of zip file if it exists
363393
if os.path.exists(rm_dir_zip):
364-
shutil.copy(rm_dir_zip, rm_dir_zip + "_backup")
394+
shutil.move(rm_dir_zip, rm_dir_zip + "_backup")
365395

366396
base_name = prefix + "-" + region + "-stacks"
367397
shutil.rmtree("modules")

cd3_automation_toolkit/Identity/Groups/templates/groups-template

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ groups = {
1515
group_name = "{{ name }}"
1616
group_description = "{{ description }}"
1717
{% if matching_rule != "" %}
18-
matching_rule = "{{ matching_rule }}" # Can be null or "" for regular groups
18+
{% if '\n' not in matching_rule %}
19+
matching_rule = "{{ matching_rule }}" # Can be null or "" for regular groups
20+
{% else %}
21+
matching_rule = <<-EOF
22+
{{ matching_rule }}
23+
EOF
24+
{% endif %}
1925
{% endif %}
2026

2127
{# ##Do not modify below this line## #}

0 commit comments

Comments
 (0)