Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add first project for olam deployment #1

Merged
merged 23 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
# linux-virt-labs
# Linux and Virtualization Labs

[![License: UPL](https://img.shields.io/badge/license-UPL-green)](https://img.shields.io/badge/license-UPL-green) [![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=oracle-devrel_linux-virt-labs)](https://sonarcloud.io/dashboard?id=oracle-devrel_linux-virt-labs)

## THIS IS A NEW, BLANK REPO THAT IS NOT READY FOR USE YET. PLEASE CHECK BACK SOON!

## Introduction
MISSING

This repository contains a growing group of assets that accompany our [training material](https://oracle-samples.github.io/oltrain/), that consists of hand-on labs and videos.

## Getting Started
MISSING

Many of the scripts consist of Oracle Linux Automation Engine playbooks to deploy our lab environments on OCI.

- [Single-Host Oracle Linux Automation Manager](https://github.com/oracle-devrel/linux-virt-labs/oracle-linux-automation-manager)

### Prerequisites
MISSING

## Notes/Issues
MISSING
To run these playbooks, ensure you have the following installed and configured:

## URLs
* Nothing at this time
- Ansible
- [OCI Ansible Collection](https://oci-ansible-collection.readthedocs.io/en/latest/installation/index.html)
- [OCI Python SDK](https://docs.oracle.com/en-us/iaas/tools/python/2.122.0/installation.html)
- [SDK CLI configuration file](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#apisigningkey_topic_How_to_Generate_an_API_Signing_Key_Console)
- public SSH key

## Contributing
This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open source community.
Expand Down
15 changes: 15 additions & 0 deletions labs/olam-hello-world.yaml
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."
92 changes: 92 additions & 0 deletions oracle-linux-automation-manager/build.yaml
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
Loading