Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Misc Curriculum Updates for Antidote 0.7 #341

Merged
merged 27 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0cfb286
Updated NAPALM vqfx configs
Mierdin Jul 20, 2020
014b89b
Update utility image to python3
Mierdin Jul 20, 2020
9fe594c
Remove vqfx2/vqfx3 from terraform lesson; fix vqfx1 config
Mierdin Jul 21, 2020
faa9eba
Remove connections
Mierdin Jul 21, 2020
3f4d1a3
Fix terraform configs
Mierdin Jul 21, 2020
edaf099
Revert to 'replace' for top-level config (this is better for stage at…
Mierdin Jul 21, 2020
1687787
Fix typo and remove ping command from stage2 terraform lesson
Mierdin Jul 21, 2020
1950395
Removed vqfx2/3 from st2 lesson, fixed configurations for vqfx1
Mierdin Jul 21, 2020
1fba125
Remove screen from st2 services script
Mierdin Jul 21, 2020
92d6239
Update stackstorm image to 3.2.0 (and bionic/python3)
Mierdin Jul 21, 2020
617f689
Updated workflow stage in stackstorm lesson to de-emphasize mistral
Mierdin Jul 21, 2020
1f1e850
Fixing stackstorm event stuff
Mierdin Jul 24, 2020
2673f4a
Last stackstorm fixes
Mierdin Jul 24, 2020
31e56d9
Python3 updates for backup/inventory/template lessons
Mierdin Jul 24, 2020
4a6e093
Added alias to bash_profile
Mierdin Jul 24, 2020
2804fe3
Re-adding newlines to for loops
Mierdin Jul 24, 2020
161fc5d
Update build-configs.py scripts for py3
Mierdin Jul 24, 2020
85c0fff
Fix PyEZ vqfx configs
Mierdin Jul 24, 2020
d2ae1e2
Py3 updates to pyez guide
Mierdin Jul 24, 2020
1285d50
Update crpd version to 20.2
Mierdin Jul 27, 2020
40a411b
update vqfx configs in robot lesson
Mierdin Jul 27, 2020
46d574b
minor updates to robot lesson
Mierdin Jul 27, 2020
f120059
Update example accordingly in last robot stage
Mierdin Jul 27, 2020
88d5fab
Fix vqfx configs in salt lesson
Mierdin Jul 27, 2020
d371ea7
Update vqfx configs in stig lesson
Mierdin Jul 27, 2020
37c069c
Update STIG lesson with minor fixes and py3 updates
Mierdin Jul 27, 2020
071c338
Updated rest APIs lesson with new vqfx configs and py3 compatibility
Mierdin Jul 27, 2020
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
2 changes: 1 addition & 1 deletion images/crpd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM crpd:20.1R1.11
FROM crpd:20.2R1.10

ADD launch.sh /
ADD sshd_config /
Expand Down
4 changes: 2 additions & 2 deletions images/crpd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ TARGET_VERSION ?= latest
all: docker

docker:
gsutil cp "gs://nrelabs-curriculum-base-images/crpd/junos-routing-crpd-docker-20.1R1.11.tgz" "./junos-routing-crpd-docker-20.1R1.11.tgz"
docker load -i junos-routing-crpd-docker-20.1R1.11.tgz
gsutil cp "gs://nrelabs-curriculum-base-images/crpd/junos-routing-crpd-docker-20.2R1.10.tgz" "./crpd.tgz"
docker load -i crpd.tgz

docker build --no-cache -t antidotelabs/crpd:$(TARGET_VERSION) .
docker push antidotelabs/crpd:$(TARGET_VERSION)
5 changes: 3 additions & 2 deletions images/stackstorm/.welcome.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash

# Get st2 version based on hardcoded string in st2common
ST2_VERSION=$(/opt/stackstorm/st2/bin/python -c 'execfile("/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/__init__.py"); print __version__')
printf "Welcome to \033[1;38;5;208mStackStorm\033[0m \033[1m%s\033[0m (Ubuntu 16.04 LTS %s %s)\n" "v${ST2_VERSION}" "$(uname -o)" "$(uname -m)"
. /etc/lsb-release
ST2_VERSION=$(/opt/stackstorm/st2/bin/python -c 'exec(open("/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/__init__.py").read()); print(__version__)')
printf "Welcome to \033[1;38;5;208mStackStorm\033[0m \033[1m%s\033[0m (${DISTRIB_DESCRIPTION} %s %s)\n" "v${ST2_VERSION}" "$(uname -o)" "$(uname -m)"
printf " * Documentation: https://docs.stackstorm.com/\n"
printf " * Community: https://stackstorm.com/community-signup\n"
printf " * Forum: https://forum.stackstorm.com/\n"
Expand Down
42 changes: 24 additions & 18 deletions images/stackstorm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ubuntu:xenial
FROM ubuntu:bionic

# Lovingly borrowed and modified from https://github.com/StackStorm/st2-dockerfiles/blob/master/base/Dockerfile

ARG DEBIAN_FRONTEND=noninteractive

ARG ST2_VERSION=2.10.1
ARG ST2_VERSION=3.2.0
RUN : "${ST2_VERSION:?Docker build argument needs to be set and non-empty.}"

ENV container docker
Expand All @@ -13,7 +13,7 @@ ENV TERM xterm

# Generate and set locale to UTF-8
RUN apt-get -qq update \
&& apt-get install -y \
&& apt-get install -y gnupg wget \
curl \
locales \
&& rm -rf /var/lib/apt/lists/* \
Expand All @@ -28,18 +28,20 @@ ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
#####################################################################################################

RUN mkdir -p /data/db
RUN apt-get update
RUN apt-get install -y gnupg-curl
RUN apt-get install -y curl wget

# Add key and repo for the latest stable MongoDB (3.4)
RUN wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | apt-key add -
RUN echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" > /etc/apt/sources.list.d/mongodb-org-3.4.list


# Add key and repo for MongoDB (4.0)
RUN wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | apt-key add -
RUN echo "deb http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-4.0.list
RUN apt-get update

RUN apt-get install -y crudini
RUN apt-get install -y mongodb-org
RUN apt-get install -y rabbitmq-server
# # Add key and repo for the latest stable MongoDB (3.4)
# RUN wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | apt-key add -
# RUN echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" > /etc/apt/sources.list.d/mongodb-org-3.4.list
# RUN apt-get update

RUN apt-get install -y crudini mongodb-org rabbitmq-server

#####################################################################################################
## Install StackStorm
Expand All @@ -55,22 +57,26 @@ RUN curl -sf https://packagecloud.io/install/repositories/StackStorm/stable/scri
ADD htpasswd /etc/st2/htpasswd

RUN echo "stanley:stanley" | chpasswd
ADD start_st2_services.sh /
ADD start_st2_services.sh start_st2_services_and_ssh.sh /

#####################################################################################################
## Additional installations / configuration
#####################################################################################################

RUN apt-get update && apt-get install -y openssh-server python git vim screen
ADD napalm.yaml /opt/stackstorm/configs
RUN cp -r /usr/share/doc/st2/examples/ /opt/stackstorm/packs/

# For some reason, in 3.x, /usr/share/doc/st2/examples/ is empty other than the directory structure. So I'm doing this to get
# the examples pack.
RUN git clone -b v${ST2_VERSION} https://github.com/StackStorm/st2 && cp -r st2/contrib/examples/ /opt/stackstorm/packs/
RUN ls -lha /opt/stackstorm/packs/examples/actions/workflows/

ARG CACHEBUST=1
RUN screen -d -m /start_st2_services.sh && sleep 15 \
RUN /start_st2_services.sh && sleep 15 \
&& st2ctl reload --register-all \
&& st2 run packs.setup_virtualenv packs=examples \
&& st2 pack remove napalm && st2 pack install https://github.com/nre-learning/stackstorm-napalm.git
RUN /opt/stackstorm/virtualenvs/napalm/bin/pip install ncclient==0.6.0
RUN /opt/stackstorm/virtualenvs/napalm/bin/pip install --upgrade netmiko==2.4.2

ARG CACHEBUST=0

#####################################################################################################
Expand Down Expand Up @@ -108,4 +114,4 @@ RUN echo "auth required pam_wheel.so use_uid" >> /etc/pam.d/su
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

CMD /start_st2_services.sh
CMD /start_st2_services_and_ssh.sh
8 changes: 0 additions & 8 deletions images/stackstorm/napalm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,3 @@ devices:
port: 22
driver: junos
credentials: junosdevices
- hostname: vqfx2
port: 22
driver: junos
credentials: junosdevices
- hostname: vqfx3
port: 22
driver: junos
credentials: junosdevices
25 changes: 12 additions & 13 deletions images/stackstorm/start_st2_services.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/bin/bash


screen -d -t mongodb -m /usr/bin/mongod
screen -d -t rabbitmq -m rabbitmq-server
/usr/bin/mongod &
rabbitmq-server &
sleep 10
screen -d -t st2actionrunner -m /opt/stackstorm/st2/bin/st2actionrunner --config-file=/etc/st2/st2.conf
screen -d -t st2api -m /opt/stackstorm/st2/bin/st2api --config-file=/etc/st2/st2.conf
screen -d -t st2auth -m /opt/stackstorm/st2/bin/st2auth --config-file=/etc/st2/st2.conf
screen -d -t st2notifier -m /opt/stackstorm/st2/bin/st2notifier --config-file=/etc/st2/st2.conf
screen -d -t st2rulesengine -m /opt/stackstorm/st2/bin/st2rulesengine --config-file=/etc/st2/st2.conf
screen -d -t st2scheduler -m /opt/stackstorm/st2/bin/st2scheduler --config-file=/etc/st2/st2.conf
screen -d -t st2sensorcontainer -m /opt/stackstorm/st2/bin/st2sensorcontainer --config-file=/etc/st2/st2.conf
screen -d -t st2stream -m /opt/stackstorm/st2/bin/st2stream --config-file=/etc/st2/st2.conf
screen -d -t st2timersengine -m /opt/stackstorm/st2/bin/st2timersengine --config-file=/etc/st2/st2.conf
screen -d -t st2workflowengine -m /opt/stackstorm/st2/bin/st2workflowengine --config-file=/etc/st2/st2.conf
/opt/stackstorm/st2/bin/st2actionrunner --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2api --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2auth --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2notifier --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2rulesengine --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2scheduler --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2sensorcontainer --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2stream --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2timersengine --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2workflowengine --config-file=/etc/st2/st2.conf &

/usr/sbin/sshd -D
18 changes: 18 additions & 0 deletions images/stackstorm/start_st2_services_and_ssh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash


/usr/bin/mongod &
rabbitmq-server &
sleep 10
/opt/stackstorm/st2/bin/st2actionrunner --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2api --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2auth --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2notifier --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2rulesengine --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2scheduler --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2sensorcontainer --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2stream --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2timersengine --config-file=/etc/st2/st2.conf &
/opt/stackstorm/st2/bin/st2workflowengine --config-file=/etc/st2/st2.conf &

/usr/sbin/sshd -D
10 changes: 5 additions & 5 deletions images/utility/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:18.04

RUN apt-get update && apt-get install -y openssh-server python python-pip dnsutils iputils-ping git vim curl util-linux sshpass nano jq libxml2-utils
RUN apt-get update && apt-get install -y openssh-server python3 python3-pip dnsutils iputils-ping git vim curl util-linux sshpass nano jq libxml2-utils
RUN mkdir /var/run/sshd

# Antidote user
Expand Down Expand Up @@ -31,16 +31,16 @@ ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

ADD requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN pip3 install -r /requirements.txt

# The snapshots directory is apparently not being set up during installation so we'll do it here
RUN mkdir -p /home/antidote/jsnapy/snapshots && chown -R antidote:antidote /home/antidote/jsnapy

# Temporary fix to get NAPALM working. Long-term we should convert utility to use python 3
RUN pip install --upgrade netmiko==2.4.2

RUN curl -L -o yq https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_amd64 && chmod +x yq && mv yq /usr/local/bin
RUN wget https://github.com/sharkdp/bat/releases/download/v0.15.4/bat_0.15.4_amd64.deb && dpkg -i bat_0.15.4_amd64.deb

COPY bash_profile /home/antidote/.bash_profile
RUN chown antidote:antidote /home/antidote/.bash_profile

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
3 changes: 1 addition & 2 deletions images/utility/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ TARGET_VERSION ?= latest
all: docker

docker:
# docker build --pull --no-cache -t antidotelabs/utility:$(TARGET_VERSION) .
docker build --pull -t antidotelabs/utility:$(TARGET_VERSION) .
docker build --pull --no-cache -t antidotelabs/utility:$(TARGET_VERSION) .
docker push antidotelabs/utility:$(TARGET_VERSION)
1 change: 1 addition & 0 deletions images/utility/bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alias python="/usr/bin/python3"
2 changes: 1 addition & 1 deletion lessons/config-backup-automated/stage0/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dev.open()
Then we will use the `rpc.get_config` function to pull the device configuration and store it in a variable called `config`. Next we `write` the configuration to the local file and finally `close` the local file.
<pre>
config = dev.rpc.get_config(options={'format':'set'})
outfile.write(etree.tostring(config))
outfile.write(etree.tostring(config).decode("utf-8"))
outfile.close()
</pre>
<button type="button" class="btn btn-primary btn-sm" onclick="runSnippetInTab('linux1', this)">Run this snippet</button>
Expand Down
4 changes: 2 additions & 2 deletions lessons/config-backup-automated/stage1/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ deviceList = yaml.full_load(deviceFile)

To ensure the `devices.yml` file was processed correctly we can print the `deviceList` variable.
<pre>
print deviceList
print(deviceList)
</pre>
<button type="button" class="btn btn-primary btn-sm" onclick="runSnippetInTab('linux1', this)">Run this snippet</button>

Expand All @@ -42,7 +42,7 @@ for device in deviceList:
dev.open()
outfile = open(device + "-backup.txt","w")
config = dev.rpc.get_config(options={'format':'text'})
outfile.write(etree.tostring(config))
outfile.write(etree.tostring(config).decode("utf-8"))
outfile.close()

</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,7 @@
</providers>
</extensions>
</system>
<interfaces operation="replace">
<interface>
<name>em0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>{{ mgmt_addr }}</name>
</address>
</inet>
</family>
</unit>
</interface>
<interfaces operation="merge">
<interface>
<name>em1</name>
<unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,7 @@
</providers>
</extensions>
</system>
<interfaces operation="replace">
<interface>
<name>em0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>{{ mgmt_addr }}</name>
</address>
</inet>
</family>
</unit>
</interface>
<interfaces operation="merge">
<interface>
<name>em1</name>
<unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,7 @@
</providers>
</extensions>
</system>
<interfaces operation="replace">
<interface>
<name>em0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>{{ mgmt_addr }}</name>
</address>
</inet>
</family>
</unit>
</interface>
<interfaces operation="merge">
<interface>
<name>em1</name>
<unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,7 @@
</providers>
</extensions>
</system>
<interfaces operation="replace">
<interface>
<name>em0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>{{ mgmt_addr }}</name>
</address>
</inet>
</family>
</unit>
</interface>
<interfaces operation="merge">
<interface>
<name>em1</name>
<unit>
Expand Down
13 changes: 0 additions & 13 deletions lessons/pyez-junos-automation/stage0/configs/vqfx-junos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,6 @@
</extensions>
</system>
<interfaces operation="merge">
<interface>
<name>em0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>{{ mgmt_addr }}</name>
</address>
</inet>
</family>
</unit>
</interface>
<interface>
<name>em3</name>
<unit>
Expand Down
13 changes: 0 additions & 13 deletions lessons/pyez-junos-automation/stage1/configs/vqfx-junos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,6 @@
</extensions>
</system>
<interfaces operation="merge">
<interface>
<name>em0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>{{ mgmt_addr }}</name>
</address>
</inet>
</family>
</unit>
</interface>
<interface>
<name>em3</name>
<unit>
Expand Down
13 changes: 0 additions & 13 deletions lessons/pyez-junos-automation/stage2/configs/vqfx-junos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,6 @@
</extensions>
</system>
<interfaces operation="merge">
<interface>
<name>em0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>{{ mgmt_addr }}</name>
</address>
</inet>
</family>
</unit>
</interface>
<interface>
<name>em3</name>
<unit>
Expand Down
Loading