Skip to content

Commit

Permalink
chore: update README with diagram
Browse files Browse the repository at this point in the history
reorganize folder structure
  • Loading branch information
kral2 authored Oct 12, 2021
1 parent da60f90 commit dbea075
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ packer-manifest.json
*pkrvars.hcl

hosts.ini
all
all

ignored
35 changes: 35 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Copyright (c) 2019, 2021 Oracle and/or its affiliates.

The Universal Permissive License (UPL), Version 1.0

Subject to the condition set forth below, permission is hereby granted to any
person obtaining a copy of this software, associated documentation and/or data
(collectively the "Software"), free of charge and under any and all copyright
rights in the Software, and any and all patent rights owned or freely
licensable by each licensor hereunder covering either (i) the unmodified
Software as contributed to or provided by such licensor, or (ii) the Larger
Works (as defined below), to deal in both

(a) the Software, and
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
one is included with the Software (each a "Larger Work" to which the Software
is contributed by such licensors),

without restriction, including without limitation the rights to copy, create
derivative works of, display, perform, and distribute the Software and make,
use, sell, offer for sale, import, export, have made, and have sold the
Software and the Larger Work(s), and to sublicense the foregoing rights on
either these or other terms.

This license is subject to the following condition:
The above copyright notice and either this complete permission notice or at
a minimum a reference to the UPL must be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# IACBOX
# HashiStack on OCI

## Build, Provision and Run a 3-nodes Nomad cluster on OCI "Always-Free" Tier

[![release](https://img.shields.io/github/v/release/kral2/hashistack_on_oci?colorB=2067b8)](https://github.com/kral2/hashistack_on_oci)
[![hcl](https://img.shields.io/badge/language-hcl-89e051.svg?style=flat-square)](https://github.com/kral2/hashistack_on_oci)
[![bash](https://img.shields.io/badge/language-bash-89e051.svg?style=flat-square)](https://github.com/kral2/hashistack_on_oci)
[![bash](https://img.shields.io/badge/language-ansible-89e051.svg?style=flat-square)](https://github.com/kral2/hashistack_on_oci)
[![license](https://img.shields.io/github/license/kral2/hashistack_on_oci?colorB=2067b8)](https://github.com/kral2/hashistack_on_oci)

## Table of Contents

Expand All @@ -10,7 +18,13 @@

## About

This module build an HashiStack demo on OCI.
This module build an HashiStack demo on OCI. It is a 3-step workflow:

1. BUILD, using Packer, Ansible, Bash scripts. The output is a Custom Image ready to deploy Nomad nodes on Linux/aarch
2. PROVISION using Terraform Registry, Terraform Cloud, OCI. The output is an OCI Networking structure and security rules, together with 3 Computes Instances and a bastion host
3. RUN : Nomad on a 3-nodes cluster, with some example jobs to come

![diagram](https://github.com/kral2/hashistack_on_oci/blob/main/_files/3-Steps_workflow.png?raw=true&sanitize=true)

<!-- BEGIN_TF_DOCS -->

Expand Down
Binary file added _files/3-Steps_workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions _files/download_hashistack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# Getting latest HashiStack components

# This is a small helper script that calls hashistack-installer to Install Nomad, Consul and Vault.
# At the moment, only Nomad is used. But that's so simple and low cost to retrieve the other runtimes, so why not :-)
# If/when https://iac.sh evovles to support the installation of HashiCorp products other than Terraform and Packer,
# we may switch to it instead of my current installer.

curl -LO https://raw.github.com/kral2/hashistack-installer/main/hashistack-install.sh
chmod +x hashistack-install.sh
./hashistack-install.sh consul vault nomad
4 changes: 4 additions & 0 deletions files/install_docker_ol7.sh → _files/install_docker_ol7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# Author: [email protected]
# Description: Install Docker Engine and cli on an Oracle Linux 7 instance running on OCI.

# OL7 repos contains old Docker version (19.xx), so we retrieve the packages from CentOS yum repo.
# OL8 have dropped support for Docker Engine and moved to Podman.
# As Nomad's Podman driver gains maturity, we may consider switching to OL8 with Podman as the container engine.

# Get OS Release number
OS_RELEASE=$(rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release))
OS_RELEASE_MAJOR=$(echo $OS_RELEASE | cut -d. -f1)
Expand Down
2 changes: 2 additions & 0 deletions files/client.hcl → _files/nomad_config/client.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Nomad config file

client {
enabled = true
}
2 changes: 2 additions & 0 deletions files/nomad.hcl → _files/nomad_config/nomad.hcl
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Nomad config file

datacenter = "fra"
data_dir = "/opt/nomad"
File renamed without changes.
2 changes: 2 additions & 0 deletions files/server.hcl → _files/nomad_config/server.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Nomad config file

server {
enabled = true
bootstrap_expect = 3
Expand Down
44 changes: 30 additions & 14 deletions build/ansible/nomad_2_install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,73 @@
become_user: root

tasks:
- name: Create Nomad directories if they do not exist
- name: Ensure Nomad directories are present
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: '0740'
mode: '0755'
with_items:
- /opt/nomad
- /etc/nomad.d
tags: global

- name: Nomad service
- name: Ebsure Nomad service unit file is present
ansible.builtin.copy:
src: ../../files/nomad.service
src: ../../_files/nomad_config/nomad.service
dest: /etc/systemd/system/nomad.service
owner: root
group: root
mode: '0660'
mode: '0665'

- name: Configuration files
- name: Ensure Nomad Configuration files are present
ansible.builtin.copy:
src: "{{ item }}"
dest: /etc/nomad.d/
mode: '700'
mode: '744'
with_items:
- ../../files/nomad.hcl
- ../../files/server.hcl
- ../../files/client.hcl
- ../../_files/nomad_config/nomad.hcl
- ../../_files/nomad_config/server.hcl
- ../../_files/nomad_config/client.hcl

- name: Configure firewalld | allow 4647/tcp inbound
- name: Ensure Nomad Demo files are present
ansible.builtin.copy:
src: "{{ item }}"
dest: /home/opc
mode: '744'
with_items:
- ../../run/bff_nomad_consul.sh
- ../../run/nginx-consul.nomad

- name: Configure firewalld | Nomad RPC (Client)
firewalld:
port: 4647/tcp
permanent: yes
immediate: yes
state: enabled
become: yes
become_user: root
- name: Configure firewalld | allow 4648/tcp inbound
- name: Configure firewalld | Nomad GOSSIP /tcp (Server)
firewalld:
port: 4648/tcp
permanent: yes
immediate: yes
state: enabled
become: yes
become_user: root
- name: Configure firewalld | allow 4648/udp inbound
- name: Configure firewalld | Nomad GOSSIP /udp (Server)
firewalld:
port: 4648/udp
permanent: yes
immediate: yes
state: enabled
become: yes
become_user: root

- name: Configure firewalld | Consul UI
firewalld:
port: 8500/tcp
permanent: yes
immediate: yes
state: enabled
become: yes
become_user: root
...
4 changes: 2 additions & 2 deletions build/nomad.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ build {
sources = ["source.oracle-oci.custom_image"]

provisioner "shell" {
scripts = ["../files/download_hashistack.sh"]
scripts = ["../_files/download_hashistack.sh"]
}

provisioner "ansible" {
Expand All @@ -58,7 +58,7 @@ build {
}

provisioner "shell" {
scripts = ["../files/install_docker_ol7.sh"]
scripts = ["../_files/install_docker_ol7.sh"]
}

post-processor "manifest" {
Expand Down
6 changes: 0 additions & 6 deletions files/download_hashistack.sh

This file was deleted.

0 comments on commit dbea075

Please sign in to comment.