-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1580 from stdweird/cumulus_init
metaconfig: cumulus: basic initialisation script and bgp frr support
- Loading branch information
Showing
9 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
router bgp [% bgp.asn %] [% vrf %] | ||
[% FILTER indent(' ') -%] | ||
bgp router-id [% bgp.routerid %] | ||
neighbor [% bgp.external %] remote-as external | ||
! | ||
address-family ipv4 unicast | ||
[% FILTER indent(' ') -%] | ||
[% FOREACH network IN bgp.ipv4 -%] | ||
network [% network %] | ||
[% END -%] | ||
[% END -%] | ||
exit-address-family | ||
[% END -%] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
ncm-metaconfig/src/main/metaconfig/cumulus/initialise_sh.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
[% fqdn = CCM.contents.hostname _ "." _ CCM.contents.domainname -%] | ||
|
||
hostnamectl set-hostname [% fqdn %] | ||
sed -i '/[% CCM.contents.ip %]/d;/[% fqdn %]/d' /etc/hosts | ||
echo "[% CCM.contents.ip %] [% fqdn %] [% CCM.contents.hostname %]" >> /etc/hosts | ||
|
||
timedatectl set-timezone '[% CCM.contents.timezone %]' | ||
dpkg-reconfigure --frontend noninteractive tzdata | ||
|
||
apt-get -o "Dpkg::Options::=--force-confold" update -y --force-yes | ||
apt-get -o "Dpkg::Options::=--force-confold" dist-upgrade -y --force-yes | ||
|
||
[% IF CCM.contents.defined('root_keys') %] | ||
mkdir -p /root/.ssh | ||
chmod 700 /root/.ssh | ||
|
||
rm -f /root/.ssh/authorized_keys | ||
cat > /root/.ssh/authorized_keys <<EOF | ||
[% CCM.contents.root_keys.join("\n") %] | ||
EOF | ||
chmod 600 /root/.ssh/authorized_keys | ||
chown root.root /root/.ssh | ||
chown root.root /root/.ssh/authorized_keys | ||
[% END %] | ||
|
||
[% IF CCM.contents.defined('cumulus_keys') %] | ||
mkdir -p /home/cumulus/.ssh | ||
chmod 700 /home/cumulus/.ssh | ||
|
||
rm -f /home/cumulus/.ssh/authorized_keys | ||
cat > /home/cumulus/.ssh/authorized_keys <<EOF | ||
[% CCM.contents.cumulus_keys.join("\n") %] | ||
EOF | ||
chmod 600 /home/cumulus/.ssh/authorized_keys | ||
chown cumulus.cumulus /home/cumulus/.ssh | ||
chown cumulus.cumulus /home/cumulus/.ssh/authorized_keys | ||
[% END %] | ||
|
||
|
||
echo "If all went fine, please reboot" |
8 changes: 8 additions & 0 deletions
8
ncm-metaconfig/src/main/metaconfig/cumulus/pan/initialise.pan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
unique template metaconfig/cumulus/initialise; | ||
|
||
include 'metaconfig/cumulus/schema'; | ||
|
||
bind "/software/components/metaconfig/services/{/home/cumulus/initialise.sh}/contents" = cumulus_initialise; | ||
|
||
prefix "/software/components/metaconfig/services/{/home/cumulus/initialise.sh}"; | ||
"module" = "cumulus/initialise_sh"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
ncm-metaconfig/src/main/metaconfig/cumulus/tests/profiles/initialise.pan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
object template initialise; | ||
|
||
include 'metaconfig/cumulus/initialise'; | ||
|
||
prefix "/software/components/metaconfig/services/{/home/cumulus/initialise.sh}/contents"; | ||
"domainname" = "bb.cc.dd"; | ||
"hostname" = "aa"; | ||
"ip" = "1.2.3.4"; | ||
"timezone" = "Europe/Brussels"; | ||
"root_keys" = list("root key 1", "root key 2"); | ||
"cumulus_keys" = list("cumulus key 1", "cumulus key 2"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
ncm-metaconfig/src/main/metaconfig/cumulus/tests/regexps/initialise/base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Cumulus initialisation script | ||
--- | ||
/home/cumulus/initialise.sh | ||
quote | ||
--- | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
|
||
hostnamectl set-hostname aa.bb.cc.dd | ||
sed -i '/1.2.3.4/d;/aa.bb.cc.dd/d' /etc/hosts | ||
echo "1.2.3.4 aa.bb.cc.dd aa" >> /etc/hosts | ||
|
||
timedatectl set-timezone 'Europe/Brussels' | ||
dpkg-reconfigure --frontend noninteractive tzdata | ||
|
||
apt-get -o "Dpkg::Options::=--force-confold" update -y --force-yes | ||
apt-get -o "Dpkg::Options::=--force-confold" dist-upgrade -y --force-yes | ||
|
||
|
||
mkdir -p /root/.ssh | ||
chmod 700 /root/.ssh | ||
|
||
rm -f /root/.ssh/authorized_keys | ||
cat > /root/.ssh/authorized_keys <<EOF | ||
root key 1 | ||
root key 2 | ||
EOF | ||
chmod 600 /root/.ssh/authorized_keys | ||
chown root.root /root/.ssh | ||
chown root.root /root/.ssh/authorized_keys | ||
|
||
|
||
|
||
mkdir -p /home/cumulus/.ssh | ||
chmod 700 /home/cumulus/.ssh | ||
|
||
rm -f /home/cumulus/.ssh/authorized_keys | ||
cat > /home/cumulus/.ssh/authorized_keys <<EOF | ||
cumulus key 1 | ||
cumulus key 2 | ||
EOF | ||
chmod 600 /home/cumulus/.ssh/authorized_keys | ||
chown cumulus.cumulus /home/cumulus/.ssh | ||
chown cumulus.cumulus /home/cumulus/.ssh/authorized_keys | ||
|
||
|
||
|
||
echo "If all went fine, please reboot" |