Skip to content

Commit 1f58f1e

Browse files
committed
Updates for v1.9 orc8r
1 parent 9e9118c commit 1f58f1e

File tree

2 files changed

+121
-5
lines changed

2 files changed

+121
-5
lines changed

orc8r-deployer/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Orc8r Deployer has two primary approaches:
99
This document describes the Quick install process: https://magma.github.io/magma/docs/next/orc8r/deploy_using_ansible
1010

1111
```bash
12-
sudo bash -c "$(curl -sL https://github.com/magma/magma-deployer/raw/main/deploy-orc8r.sh)"
12+
sudo bash -c "$(curl -sL https://raw.githubusercontent.com/magma/magma-deployer/main/orc8r-deployer/deploy-orc8r.sh)"
1313
```
1414

1515
## Customized Deployer
@@ -21,10 +21,8 @@ To start the process, create a deployer working environment. Do this from a logi
2121
```bash
2222
# As ubuntu user
2323
cd ~
24-
git clone https://github.com/jblakley/magma-deployer # To change after upstreamed
25-
cd magma-deployer
26-
git checkout agw-orc8r # To change after upstreamed
27-
cd orc8r-deployer
24+
git clone https://github.com/magma/magma-deployer
25+
cd magma-deployer/orc8r-deployer
2826
sudo bash ./deploy-orc8r-bootstrap.sh $(cd ..;pwd)
2927
sudo su - magma
3028
```
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Check if the system is Linux
6+
if [ $(uname) != "Linux" ]; then
7+
echo "This script is only for Linux"
8+
exit 1
9+
fi
10+
11+
# Run as root user
12+
if [ $(id -u) != 0 ]; then
13+
echo "Please run as root user"
14+
exit 1
15+
fi
16+
17+
DEFAULT_ORC8R_DOMAIN="magma.local"
18+
DEFAULT_NMS_ORGANIZATION_NAME="magma-test"
19+
DEFAULT_NMS_EMAIL_ID_AND_PASSWORD="admin"
20+
DEFAULT_MAGMA_API_PASSWORD="password"
21+
DEFAULT_RUN_PLAYBOOK="N"
22+
DEFAULT_DEPLOYER_PATH="$1"
23+
DEFAULT_ORC8R_IP=$(hostname -I | awk '{print $1}')
24+
GITHUB_USERNAME="jblakley"
25+
GITHUB_DEPLOYER_BRANCH="main"
26+
# MAGMA_DOCKER_REGISTRY="magmacore"
27+
MAGMA_DEPLOYER_REPO="magma-deployer"
28+
MAGMA_USER="magma"
29+
HOSTS_FILE="hosts.yml"
30+
31+
# Take input from user
32+
read -p "Your Magma Orchestrator domain name? [${DEFAULT_ORC8R_DOMAIN}]: " ORC8R_DOMAIN
33+
ORC8R_DOMAIN="${ORC8R_DOMAIN:-${DEFAULT_ORC8R_DOMAIN}}"
34+
35+
read -p "NMS organization(subdomain) name you want? [${DEFAULT_NMS_ORGANIZATION_NAME}]: " NMS_ORGANIZATION_NAME
36+
NMS_ORGANIZATION_NAME="${NMS_ORGANIZATION_NAME:-${DEFAULT_NMS_ORGANIZATION_NAME}}"
37+
38+
read -p "Set your email ID for NMS? [${DEFAULT_NMS_EMAIL_ID_AND_PASSWORD}]: " NMS_EMAIL_ID
39+
NMS_EMAIL_ID="${NMS_EMAIL_ID:-${DEFAULT_NMS_EMAIL_ID_AND_PASSWORD}}"
40+
41+
read -p "Set your password for NMS? [${DEFAULT_NMS_EMAIL_ID_AND_PASSWORD}]: " NMS_PASSWORD
42+
NMS_PASSWORD="${NMS_PASSWORD:-${DEFAULT_NMS_EMAIL_ID_AND_PASSWORD}}"
43+
44+
read -p "Set your password for the API Browser Certificate? [${DEFAULT_MAGMA_API_PASSWORD}]: " MAGMA_API_PASSWORD
45+
MAGMA_API_PASSWORD="${MAGMA_API_PASSWORD:-${DEFAULT_MAGMA_API_PASSWORD}}"
46+
47+
read -p "Set the Orchestrator IP Address [${DEFAULT_ORC8R_IP}]: " ORC8R_IP
48+
ORC8R_IP="${ORC8R_IP:-${DEFAULT_ORC8R_IP}}"
49+
50+
read -p "If you've already cloned magma-deployer, enter the path here: [${DEFAULT_DEPLOYER_PATH}]: " DEPLOYER_PATH
51+
DEPLOYER_PATH="${DEPLOYER_PATH:-${DEFAULT_DEPLOYER_PATH}}"
52+
53+
read -p "Run ansible-playbook deploy-orc8r.sh on completion? [y/N]: [${DEFAULT_RUN_PLAYBOOK}]: " RUN_PLAYBOOK
54+
RUN_PLAYBOOK="${RUN_PLAYBOOK:-${DEFAULT_RUN_PLAYBOOK}}"
55+
56+
test -d /tmp/magma-deployer/ && rm -rf /tmp/magma-deployer/
57+
test -d "${DEPLOYER_PATH}" && cp -pr ${DEPLOYER_PATH} /tmp/magma-deployer/
58+
59+
# Add repos for installing yq and ansible
60+
ls /etc/apt/sources.list.d|grep yq || add-apt-repository --yes ppa:rmescandon/yq
61+
ls /etc/apt/sources.list.d|grep ansible || add-apt-repository --yes ppa:ansible/ansible
62+
63+
# Install yq and ansible
64+
which yq || apt install yq -y
65+
which ansible || apt install ansible -y
66+
67+
# Create magma user and give sudo permissions
68+
id ${MAGMA_USER} || useradd -m ${MAGMA_USER} -s /bin/bash -G sudo
69+
grep ${MAGMA_USER} /etc/sudoers || echo "${MAGMA_USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
70+
71+
# switch to magma user
72+
su - ${MAGMA_USER} -c bash <<_
73+
echo ENTERING MAGMA USER EXECUTION
74+
# Genereta SSH key for magma user
75+
test -f ~/.ssh/id_rsa.pub || ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''
76+
test -f ~/.ssh/authorized_keys || cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
77+
78+
test -d "~/magma-deployer" && rm -rf ~/magma-deployer
79+
80+
if test -d /tmp/magma-deployer
81+
then
82+
cp -pr /tmp/magma-deployer ~/
83+
else
84+
# Clone Magma Deployer repo
85+
cd ~
86+
git clone https://github.com/${GITHUB_USERNAME}/${MAGMA_DEPLOYER_REPO} --depth 1
87+
fi
88+
89+
cd ~/${MAGMA_DEPLOYER_REPO}
90+
git checkout "${GITHUB_DEPLOYER_BRANCH}"
91+
cd orc8r-deployer
92+
93+
# export variables for yq
94+
export ORC8R_IP=${ORC8R_IP}
95+
export MAGMA_USER=${MAGMA_USER}
96+
export ORC8R_DOMAIN=${ORC8R_DOMAIN}
97+
export NMS_ORGANIZATION_NAME=${NMS_ORGANIZATION_NAME}
98+
export NMS_EMAIL_ID=${NMS_EMAIL_ID}
99+
export NMS_PASSWORD=${NMS_PASSWORD}
100+
export MAGMA_API_PASSWORD=${MAGMA_API_PASSWORD}
101+
export RUN_PLAYBOOK=${RUN_PLAYBOOK}
102+
103+
# Update values to the config file
104+
yq e '.all.hosts = env(ORC8R_IP)' -i ${HOSTS_FILE}
105+
yq e '.all.vars.ansible_user = env(MAGMA_USER)' -i ${HOSTS_FILE}
106+
yq e '.all.vars.orc8r_domain = env(ORC8R_DOMAIN)' -i ${HOSTS_FILE}
107+
yq e '.all.vars.nms_org = env(NMS_ORGANIZATION_NAME)' -i ${HOSTS_FILE}
108+
yq e '.all.vars.nms_id = env(NMS_EMAIL_ID)' -i ${HOSTS_FILE}
109+
yq e '.all.vars.nms_pass = env(NMS_PASSWORD)' -i ${HOSTS_FILE}
110+
yq e '.all.vars.magma_api_password = env(MAGMA_API_PASSWORD)' -i ${HOSTS_FILE}
111+
112+
# Deploy Magma Orchestrator
113+
if [ "${RUN_PLAYBOOK}" = "y" ]; then
114+
ansible-playbook deploy-orc8r.yml
115+
fi
116+
_
117+
118+
rm -rf /tmp/magma-deployer

0 commit comments

Comments
 (0)