Skip to content

Enables the management(start/stop) of oci resources using gitlab, ansible and terraform.

License

Notifications You must be signed in to change notification settings

romuloslv/start-stop-oci-iac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

start-stop-oci-iac

Enables the management of oci resources


Prerequisites

  • Tag created at OCI
  • Vault created at OCI
  • Variables, schedules, and configuration file created in Gitlab
  • Tag the loadbalancer, dbsystem, and instance type resources you want to manage

Supported services

  • Oracle Cloud Compute: On/Off
  • Oracle Cloud DBSystem: On/Off
  • Oracle Cloud Flexible LB: Up/Down

Schedule activities on the oracle_cloud branch

Turn off resources | yourtenancyname | yourcompartmentname
Turn on resources | yourtenancyname | yourcompartmentname

Available variables for schedules

ANSIBLE_ENVS ->> The value of the ANSIBLE_ENVS variable contains the environments where the resources should be changed.
for example: ANSIBLE_ENVS=@(dev|qa). The resources will be changed in these environments.

ANSIBLE_ACT - > > The value of the ANSIBLE_ACT variable contains the action to be performed.
e.g.: ANSIBLE_ACT=stop. Changes the status of the resources in these environments.

The changes must be replicated between active schedules.

e.g.: ANSIBLE_ENVS=@(dev|qa|uat|stg). Changes (starts/stops) resources in these environments.
e.g.: ANSIBLE_ENVS=@(dev|qa). This keeps the environments uat/stg in their state.

Default environments

  • dev
  • qa
  • uat
  • stg

TL;DR

Replace 'changeme' with your information in:

docker/requirements/config
.gitlab/_terraform/terraform.tfvars
.gitlab/_ansible/manager_resources.


Run Terraform to upload the required infrastructure

$ terraform init
$ terraform fmt
$ terraform validate
$ terraform plan
$ terraform apply -auto-approve

Configuration examples can be found in the image repository, and general information can be found on the INFO page of the respective root directory.
Finally, fork this repository on github to your branch created in the gitlab repository. The marked environments will be activated at 07:50 and deactivated at 21:50 Brasilia local time.