-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (75 loc) · 3.52 KB
/
deploy-tools.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: deploy-tools
on:
workflow_dispatch:
jobs:
deploy_nso:
runs-on:
group: customer-demos
env:
NSO_URL: ${{ secrets.NSO_URL }}
NSO_HOST: ${{ secrets.NSO_HOST }}
AWS_S3_URL: ${{ secrets.AWS_S3_URL }}
AWS_S3_URI: ${{ secrets.AWS_S3_URI }}
AWS_S3_KEY_NAME: ${{ secrets.AWS_S3_KEY_NAME }}
AWS_S3_REGION: ${{ secrets.AWS_S3_REGION }}
container:
image: ghcr.io/model-driven-devops/mdd:latest
steps:
- name: Checkout Inventory
uses: actions/checkout@v4
- name: Setup SSH Agent in Container
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
ssh-keyscan -H $NSO_HOST >> ~/.ssh/known_hosts
- name: NSO install
env:
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_SSH_ARGS: "-o ForwardAgent=yes"
run: |
ansible-playbook ciscops.mdd.nso_install -vvvv
ansible-playbook ciscops.mdd.nso_update_packages
ansible-playbook ciscops.mdd.nso_init
working-directory: ./mdd
deploy_netbox:
runs-on:
group: customer-demos
env:
NETBOX_HOST: ${{ secrets.NETBOX_HOST }}
steps:
- name: Checkout Inventory
uses: actions/checkout@v4
- name: Convert Script Line Endings
run: |
sed -i 's/\r$//' ./scripts/docker-install.sh
sed -i 's/\r$//' ./scripts/netbox-install.sh
working-directory: ./mdd
- name: Setup SSH Key in Temporary Directory
run: |
SSH_DIR=$(mktemp -d)
SSH_KEY="$SSH_DIR/id_rsa"
echo "${{ secrets.SSH_PRIVATE_KEY }}" > "$SSH_KEY"
chmod 600 "$SSH_KEY"
ssh-keyscan -t rsa,ecdsa-sha2-nistp256 $NETBOX_HOST >> "$SSH_DIR/known_hosts"
echo "SSH_DIR=$SSH_DIR" >> $GITHUB_ENV
echo "SSH_KEY=$SSH_KEY" >> $GITHUB_ENV
- name: Copy Docker Compose Script
run: |
scp -o UserKnownHostsFile="$SSH_DIR/known_hosts" -o StrictHostKeyChecking=no -o IdentityFile="$SSH_KEY" -o HostKeyAlgorithms=ssh-rsa,ecdsa-sha2-nistp256 ./scripts/docker-install.sh ubuntu@${{ secrets.NETBOX_HOST }}:/tmp/docker-install.sh
working-directory: ./mdd
- name: Execute Docker Compose Setup Script on Netbox Host
run: |
ssh -o UserKnownHostsFile="$SSH_DIR/known_hosts" -o StrictHostKeyChecking=no -o IdentityFile="$SSH_KEY" -o HostKeyAlgorithms=ssh-rsa,ecdsa-sha2-nistp256 ubuntu@${{ secrets.NETBOX_HOST }} 'bash /tmp/docker-install.sh'
- name: Copy Netbox Script
run: |
scp -o UserKnownHostsFile="$SSH_DIR/known_hosts" -o StrictHostKeyChecking=no -o IdentityFile="$SSH_KEY" -o HostKeyAlgorithms=ssh-rsa,ecdsa-sha2-nistp256 ./scripts/netbox-install.sh ubuntu@${{ secrets.NETBOX_HOST }}:/tmp/netbox-install.sh
scp -o UserKnownHostsFile="$SSH_DIR/known_hosts" -o StrictHostKeyChecking=no -o IdentityFile="$SSH_KEY" -o HostKeyAlgorithms=ssh-rsa,ecdsa-sha2-nistp256 ./netbox/netbox.service ubuntu@${{ secrets.NETBOX_HOST }}:/tmp/netbox.service
working-directory: ./mdd
- name: Execute Docker Compose Setup Script on Netbox Host
run: |
ssh -o UserKnownHostsFile="$SSH_DIR/known_hosts" -o StrictHostKeyChecking=no -o IdentityFile="$SSH_KEY" -o HostKeyAlgorithms=ssh-rsa,ecdsa-sha2-nistp256 ubuntu@${{ secrets.NETBOX_HOST }} 'bash /tmp/netbox-install.sh'