You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ci-automation/1-automation-basics.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,13 +48,13 @@ This tutorial assumes you already have some Terraform and/or OCI CLI experience.
48
48
49
49
### CLIs
50
50
51
-
CLIs are a little bit better than GUIs for helping you manage critical issues. Instead of pointing-and-clicking, commands are directly issued into the application. When you get down to it, CLIs are really just a text user interface. Most CLIs allow for running "headless", meaning they don't require continuous user input (all input can be provided at runtime). One benefit is that it's easier to use CLIs with automated workflows, so it's definitely a step in the right direction. By themselves though, it's impossible to embed any sort of logic when using CLIs, unless there's some sort of scripting (shell scripts, Ruby, Python, etc.) involved. This means that it's great to send a single command (or even a series of commands), but it can be difficult to maintain a high level of assurance without more involved scripting logic being used with the CLI.
51
+
CLIs are a little bit better than GUIs for helping you manage critical issues. Instead of pointing-and-clicking, commands are directly issued into the application. When you get down to it, CLIs are really just a text user interface. Most CLIs allow for running "headless", meaning they don't require continuous user input (all input can be provided at runtime). One benefit is that it's easier to use CLIs with automated workflows, so it's definitely a step in the right direction. By themselves though, it's impossible to embed any sort of logic when using CLIs, this is where some sort of scripting (shell scripts, Ruby, Python, etc.) can add significant benefit. After determining the set of CLI commands to run, you can utilize the scripting tool of choice to implement logic and create repeatable automation activities.
52
52
53
53
### IaC tools
54
54
55
55
When you really need to tailor your environment and maximize control over how it performs, IaC tools are what you need. IaC tools are designed from the ground-up to manage infrastructure resources using code. Resources are defined within the code, with the tool itself providing the necessary structure and logic to quickly and easily build a definition of what you need or want an environment to be. The basic "scaffolding" (logic elements, API interactions, etc.) are all abstracted, allowing you to focus on describing the resources you need or want to exist in the environment.
56
56
57
-
By far, this is one of the easiest and fastest ways to build and maintain cloud environments. But this isn't just limited to the cloud, on-premesis resources can often be managed with IaC tools as well. Are you using multiple cloud providers? Even more reason to utilize IaC in managing your IT infrastructure.
57
+
By far, this is one of the easiest and fastest ways to build and maintain cloud environments. But this isn't just limited to the cloud; on-premesis resources can often be managed with IaC tools as well. Are you using multiple cloud providers? Even more reason to utilize IaC in managing your IT infrastructure.
58
58
59
59
With IaC, it's common to use Git on the back-end. Git allows you to get a deep history of changes and its robust version control system enables easy and rapid rollbacks. Additionally, if you use Git for storing the code definitions, you're able to use standard processes and tools to monitor/approve/manage changes before they're made. Whether using policy-as-code (such as [Open Policy Agent](https://www.openpolicyagent.org), with implementations such as [Policy-as-Code on OCI using Open Policy Agent](https://github.com/oracle-devrel/oci-pac-opa)) or a manual pull request (PR)/merge request (MR) review process, you can have a really solid review/approval/compliance mechanism (not to mention yet another audit trail that's separate from the cloud/platform itself).
60
60
@@ -66,15 +66,15 @@ One of the most common and popular IaC tools is [HashiCorp Terraform](https://ww
66
66
67
67
Sometimes infrastructure isn't your major concern and what you really need are tools that predominantly operate in the realm of configuration management, such as [Ansible](https://www.ansible.com) or [Chef](https://www.chef.io)/[Cinc](https://cinc.sh). These are all options for managing infrastructure as well, but you may be better off with tools that focus exclusively on *infrastructure management*. For OCI's part, it's certainly no exception in supporting many of these different platforms.
68
68
69
-
## IaC and Terraform
69
+
## CLI and IaC (Terraform)
70
70
71
-
In the rest of this series, we're going to target using Terraform to manage OCI infrastructure. Why Terraform? It's fairly mature at this point, widely adopted, and has support for a wide variety of cloud platforms, including OCI. Additionally, there are plenty of resources available and Terraform enjoys strong user support, making it an ideal tool. Terraform is mainly targeted at managing infrastructure and not so much the configuration management side of things. But it's super powerful when combined with a traditional configuration management tool like Ansible.
71
+
For the remainder of this series we are going to explore the capabilities of CLI and IaC for deploying and managing infrastructure. We'll compare the pros and cons of each so you can ultimately make the decision regarding which fits best for your particular situation.
72
72
73
73
## What's Next
74
74
75
-
By now, you should be a little more familiar with IaC and ready to get started with Terraform!
75
+
By now, you should have a basic understanding of how to configure the tools (Command Line Interface and Terraform) illustrated in this tutorial. You're ready to dive right in and start automating.
76
76
77
-
Until your next lesson, happy coding! Take a look at the [next lesson](2-experiencing-terraform) in the Terraform 101 series and go through a very quick experience in using Terraform. From there, you'll dive into several aspects of how Terraform works.
77
+
Until your next lesson, happy coding! Take a look at the [next lesson](2-automated-deployment-cli) in the Container Instances Automation 101 series, and go through the process of deploying resources using the OCI CLI. After that, you'll experiment with Terraform before moving on to some more advanced use cases.
78
78
79
79
To explore more information about development with Oracle products:
In this tutorial we are going to build a simple virtual network environment and deploy an OCI Container Instance resource. The Container Instance will run two containers; WordPress in one, and MySQL in the other. All of the work is done at the command prompt and when you're finished, you could easily create a bash script for one-click deployment in the future.
28
28
29
-
If you do not yet have the CLI installed, [Click Here][1] to follow the instructions. WHen you're ready to go, dive right in!
29
+
This tutorial is designed for use in the OCI Cloud Shell [OCI Cloud Shell][1]. The Cloud Shell is an easy-to-use terminal built right into the OCI Console, with integrated authorization. If your preference is to install the OCI CLI elsewhere, that is also a cinch, just [Click Here][2] to follow the instructions. When you're ready to go, dive right in!
30
30
31
31
### Gather Required Information
32
32
The prep work involves identifying your preferred availability domain and working compartment. It is recommended you do not use the *root* compartment in your tenancy, however, the instructions will accommodate use of *root* if you so choose.
@@ -41,36 +41,36 @@ The command output is JSON so there are a few tricks we can use to easily captur
41
41
42
42
One more example before we move on. The following will query for the availability domain that includes "AD-1" in the name. If you'd like to use a different AD, just change the number.
43
43
44
-
oci iam availability-domain list --query 'data[?contains ("name",`AD-1`)]|[0].[id,name]' | sed 's/"//g'
44
+
oci iam availability-domain list --query 'data[?contains ("name",`AD-1`)]|[0].[id,name]' --raw-output'
45
45
46
46
Capture the availability domain id and name in environment variables.
47
47
48
-
adId=($(oci iam availability-domain list --query 'data[?contains ("name",`AD-1`)]|[0].id' | sed 's/"//g'))
48
+
adId=($(oci iam availability-domain list --query 'data[?contains ("name",`AD-1`)]|[0].id' --raw-output))
49
49
50
-
adName=($(oci iam availability-domain list --query 'data[?contains ("name",`AD-1`)]|[0].name' | sed 's/"//g'))
50
+
adName=($(oci iam availability-domain list --query 'data[?contains ("name",`AD-1`)]|[0].name' --raw-output))
51
51
52
52
You can quickly echo the values to confirm they both loaded properly:
53
53
![Screenshot of: echo command output][4]
54
54
55
55
The final piece of information required before creating resources is the Compartment OCID. In this example, our compartment name is **Training**.
56
56
57
-
compOcid=($(oci iam compartment list --query 'data[?name==`Training`]|[0].id' | sed 's/"//g'))
57
+
compOcid=($(oci iam compartment list --query 'data[?name==`Training`]|[0].id' --raw-output))
58
58
59
59
If you prefer to use the root compartment, the query looks a little different:
60
60
61
-
compOcid=($(oci iam compartment list --query 'data[0]."compartment-id"' | sed 's/"//g'))
61
+
compOcid=($(oci iam compartment list --query 'data[0]."compartment-id"' --raw-output))
62
62
63
63
### Create the network resources
64
64
We are going to create a Virtual Cloud Network (VCN) with a single public subnet, a security list that allows ingress traffic on port 80 (to access the WordPress server), an Internet Gateway, and add a route for the Internet Gateway to the default route table. Let's do this!
65
65
66
66
Create the VCN! Here we are using 10.0.0.0/16 as the network CIDR. You may opt for a different range...if you do, just make sure you change it accordingly in subsequent steps.
67
67
**Note** Because we are loading specific output directly to an environment variable, the command will return nothing to the screen unless there is an error.
@@ -118,7 +118,7 @@ If you look near the end of the output you'll find a section for the *vnics* - a
118
118
119
119
In the JSON output from the command above, locate the **id** for the container instance and copy it (or store it in an environment variable). Then run:
120
120
121
-
oci container-instances --container-instance get --container-instance-id <the id you coiped above>
121
+
oci container-instances --container-instance get --container-instance-id <the id you coieed above>
122
122
123
123
Now in the output you'll see an **id** for the vnic.
124
124
![Screenshot of: Valid vnic id value][8]
@@ -208,12 +208,13 @@ There you have it, and well done! You've just completely provisioned OCI Contain
0 commit comments