generated from oracle-devrel/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from bgraef/main
add first project for olam deployment
- Loading branch information
Showing
10 changed files
with
1,265 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# Copyright (c) 2024 Oracle and/or its affiliates. | ||
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0. | ||
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl) | ||
# See LICENSE.TXT for details. | ||
|
||
- name: Hello World sample playbook | ||
hosts: localhost | ||
gather_facts: false | ||
|
||
tasks: | ||
|
||
- name: Print welcome message | ||
ansible.builtin.debug: | ||
msg: "Hello! Welcome to Oracle Linux Automation Manager." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
# Copyright (c) 2024 Oracle and/or its affiliates. | ||
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0. | ||
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl) | ||
# See LICENSE.TXT for details. | ||
|
||
- name: Launch an instance | ||
oci_compute_instance: | ||
availability_domain: "{{ my_availability_domain }}" | ||
compartment_id: "{{ my_compartment_id }}" | ||
name: "{{ item.value.instance_name | default('instance-'~timestamp) }}" | ||
image_id: "{{ ol_image_id }}" | ||
shape: "{{ instance_shape }}" | ||
shape_config: | ||
ocpus: "{{ instance_ocpus }}" | ||
memory_in_gbs: "{{ instance_memory }}" | ||
create_vnic_details: | ||
assign_public_ip: true | ||
hostname_label: "{{ item.value.instance_name | default('instance-'~timestamp) }}" | ||
subnet_id: "{{ my_subnet_id }}" | ||
metadata: | ||
ssh_authorized_keys: "{{ lookup('file', lookup('env','HOME') + '/.ssh/' + private_key + '.pub' ) }}" | ||
agent_config: | ||
is_monitoring_disabled: false | ||
is_management_disabled: false | ||
are_all_plugins_disabled: false | ||
plugins_config: | ||
- | ||
name: "OS Management Service Agent" | ||
desired_state: DISABLED | ||
register: result | ||
vars: | ||
timestamp: "{{ now().strftime('%Y%m%d-%H%M%S') }}" | ||
|
||
- name: Print instance details | ||
ansible.builtin.debug: | ||
msg: | ||
- "Launched a new instance:" | ||
- "{{ result }}" | ||
when: debug_enabled | ||
|
||
- name: Set the compute instance id | ||
ansible.builtin.set_fact: | ||
instance_id: "{{ result.instance.id }}" | ||
|
||
- name: Set the compute instance display_name | ||
ansible.builtin.set_fact: | ||
instance_display_name: "{{ result.instance.display_name }}" | ||
|
||
- name: Get the vnic attachment details of instance | ||
oci_compute_vnic_attachment_facts: | ||
compartment_id: "{{ my_compartment_id }}" | ||
instance_id: "{{ instance_id }}" | ||
register: result | ||
|
||
- name: Get vnic details | ||
oci_network_vnic_facts: | ||
id: "{{ result.vnic_attachments[0].vnic_id }}" | ||
register: result | ||
|
||
- name: Set the instance private ip address | ||
ansible.builtin.set_fact: | ||
instance_private_ip: "{{ result.vnic.private_ip }}" | ||
|
||
- name: Set the instance public ip address | ||
ansible.builtin.set_fact: | ||
instance_public_ip: "{{ result.vnic.public_ip }}" | ||
|
||
- name: Print the public and private ip of the newly created instance | ||
ansible.builtin.debug: | ||
msg: | ||
- "Instance name: {{ instance_display_name }}" | ||
- " public ip: {{ instance_public_ip }}" | ||
- " private ip: {{ instance_private_ip }}" | ||
when: debug_enabled | ||
|
||
- name: Add host to in-memory host file | ||
ansible.builtin.add_host: | ||
name: "{{ instance_display_name }}" | ||
groups: "in_memory" | ||
ansible_user: opc | ||
ansible_ssh_private_key_file: "{{ lookup('env','HOME') + '/.ssh/' + private_key }}" | ||
ansible_ssh_common_args: "-o StrictHostKeyChecking=no" | ||
ansible_host: "{{ instance_public_ip }}" | ||
ansible_port: 22 | ||
instance_ocid: "{{ instance_id }}" | ||
|
||
# - name: Add instance to the state file | ||
# ansible.builtin.lineinfile: | ||
# path: /tmp/ansible.state | ||
# line: "id{{ groups['in_memory'].index(instance_display_name) }}: {{ instance_id }}" | ||
# create: true |
Oops, something went wrong.