Add bird_xxx types.
This commit is contained in:
parent
16b5158ef5
commit
3f0798d645
31 changed files with 1071 additions and 0 deletions
45
type/__bird_bgp/files/template.sh
Executable file
45
type/__bird_bgp/files/template.sh
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
# Template to generate a bgp protocol configuration file for bird(1).
|
||||
# Required non-empty variables:
|
||||
# __object_id, local_{ip,as}, neighbor_{ip,as}
|
||||
#
|
||||
# Required defined variables:
|
||||
# description, password, ipv{4,6}_{import,export}
|
||||
|
||||
# Header
|
||||
echo "protocol bgp ${__object_id:?} {"
|
||||
|
||||
# Optional description
|
||||
[ -n "${description?}" ] && printf "\tdescription \"%s\";\n" "${description?}"
|
||||
|
||||
# Mandatory session information
|
||||
cat << EOF
|
||||
local ${local_ip?} as ${local_as:?};
|
||||
neighbor ${neighbor_ip:?} as ${neighbor_as:?};
|
||||
EOF
|
||||
|
||||
# Direct connection ?
|
||||
[ -n "${direct?}" ] && printf "\tdirect;\n"
|
||||
|
||||
# Password-protected session ?
|
||||
[ -n "${password?}" ] && printf "\tpassword \"%s\";\n" "${password?}"
|
||||
|
||||
if [ -n "${ipv4_import?}" ] || [ -n "${ipv4_export?}" ] || "${ipv4_extended_next_hop?}";
|
||||
then
|
||||
printf "\tipv4 {\n"
|
||||
[ -n "${ipv4_import?}" ] && printf "\t\timport %s;\n" "${ipv4_import:?}"
|
||||
[ -n "${ipv4_export?}" ] && printf "\t\texport %s;\n" "${ipv4_export:?}"
|
||||
[ -n "${ipv4_extended_next_hop?}" ] && printf "\t\textended next hop;\n"
|
||||
printf "\t};\n"
|
||||
fi
|
||||
if [ -n "${ipv6_import?}" ] || [ -n "${ipv6_export?}" ] || "${ipv6_extended_next_hop?}";
|
||||
then
|
||||
printf "\tipv6 {\n"
|
||||
[ -n "${ipv6_import?}" ] && printf "\t\timport %s;\n" "${ipv6_import:?}"
|
||||
[ -n "${ipv6_export?}" ] && printf "\t\texport %s;\n" "${ipv6_export:?}"
|
||||
[ -n "${ipv6_extended_next_hop?}" ] && printf "\t\textended next hop;\n"
|
||||
printf "\t};\n"
|
||||
fi
|
||||
|
||||
# Header close
|
||||
echo "}"
|
105
type/__bird_bgp/man.rst
Normal file
105
type/__bird_bgp/man.rst
Normal file
|
@ -0,0 +1,105 @@
|
|||
cdist-type__bird_bgp(7)
|
||||
=======================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__bird_bgp - configure an instance of the BGP protocol.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This type writes the configuration for an instance of the BGP protocol to be
|
||||
ran by the bird internet routing daemon. It **expects** to depend on the
|
||||
`cdist-type__bird_core(7)` type.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
local-as
|
||||
The number for the AS in which the daemon is running.
|
||||
|
||||
neighbor-as
|
||||
The number of the AS with which we are peering.
|
||||
|
||||
neighbor-ip
|
||||
The IP address of the peer we are opening a session with.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
description
|
||||
An instance desciption to be printed when `birdc show protocols` is called.
|
||||
|
||||
local-ip
|
||||
The IP address used as a source address for the BGP session.
|
||||
|
||||
password
|
||||
A password for the BGP session.
|
||||
|
||||
ipv4-import
|
||||
A string suitable for the bird `import` directive. Usually `all`, `none` or
|
||||
a filter definition.
|
||||
|
||||
ipv4-export
|
||||
See ipv4-import.
|
||||
|
||||
ipv4-extended-next-hop
|
||||
Allow IPv6 next hop in IPv4 NLRI.
|
||||
|
||||
ipv6-import
|
||||
See ipv4-import.
|
||||
|
||||
ipv6-export
|
||||
See ipv4-import.
|
||||
|
||||
ipv6-extended-next-hop
|
||||
Allow IPv4 next hop in IPv6 NLRI.
|
||||
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
direct
|
||||
Specify that the two routers are directly connected.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Setup bird and open a BGP session.
|
||||
__bird_core --router-id 198.51.100.4
|
||||
|
||||
require='__bird_core' __bird_bgp bgp4 \
|
||||
--description "a test IPv4 BGP instance" \
|
||||
--ipv4-export all \
|
||||
--ipv4-import all \
|
||||
--ipv6-export none \
|
||||
--ipv6-import none \
|
||||
--local-as 1234 \
|
||||
--local-ip 198.51.100.4 \
|
||||
--neighbor-as 4321 \
|
||||
--neighbor-ip 198.51.100.3 \
|
||||
--password hunter01
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__bird_core(7)
|
||||
cdist-type__bird_filter(7)
|
||||
cdist-type__bird_kernel(7)
|
||||
cdist-type__bird_ospf(7)
|
||||
cdist-type__bird_static(7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2021 Joachim Desroches. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
123
type/__bird_bgp/manifest
Executable file
123
type/__bird_bgp/manifest
Executable file
|
@ -0,0 +1,123 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2021 Joachim Desroches (joachim.desroches@epfl.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "${__global:?}/explorer/os")
|
||||
|
||||
case "$os" in
|
||||
"alpine"|"debian"|"ubuntu")
|
||||
confdir="/etc/bird.d"
|
||||
;;
|
||||
*)
|
||||
printf "Your operating system (%s) is currently not supported by __bird_bgp\n" "$os" >&2
|
||||
printf "Please contribute an implementation for it if you can.\n" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Required parameters
|
||||
local_as="$(cat "${__object:?}"/parameter/local-as)"
|
||||
export local_as
|
||||
|
||||
neighbor_as="$(cat "${__object:?}"/parameter/neighbor-as)"
|
||||
export neighbor_as
|
||||
|
||||
neighbor_ip="$(cat "${__object:?}"/parameter/neighbor-ip)"
|
||||
export neighbor_ip
|
||||
|
||||
# Optional parameters
|
||||
description=
|
||||
if [ -f "${__object:?}"/parameter/description ];
|
||||
then
|
||||
description="$(cat "${__object:?}"/parameter/description)"
|
||||
fi
|
||||
export description
|
||||
|
||||
direct=
|
||||
if [ -f "${__object:?}"/parameter/direct ];
|
||||
then
|
||||
direct="true"
|
||||
fi
|
||||
export direct
|
||||
|
||||
ipv4_extended_next_hop=
|
||||
if [ -f "${__object:?}"/parameter/ipv4-extended-next-hop ];
|
||||
then
|
||||
ipv4_extended_next_hop="true"
|
||||
fi
|
||||
export ipv4_extended_next_hop
|
||||
|
||||
ipv6_extended_next_hop=
|
||||
if [ -f "${__object:?}"/parameter/ipv6-extended-next-hop ];
|
||||
then
|
||||
ipv6_extended_next_hop="true"
|
||||
fi
|
||||
export ipv6_extended_next_hop
|
||||
|
||||
local_ip=
|
||||
if [ -f "${__object:?}"/parameter/local-ip ];
|
||||
then
|
||||
local_ip="$(cat "${__object:?}"/parameter/local-ip)"
|
||||
fi
|
||||
export local_ip
|
||||
|
||||
password=
|
||||
if [ -f "${__object:?}"/parameter/password ];
|
||||
then
|
||||
password="$(cat "${__object:?}"/parameter/password)"
|
||||
fi
|
||||
export password
|
||||
|
||||
ipv4_import=
|
||||
if [ -f "${__object:?}"/parameter/ipv4-import ];
|
||||
then
|
||||
ipv4_import="$(cat "${__object:?}"/parameter/ipv4-import)"
|
||||
echo "FOO" >&2
|
||||
fi
|
||||
export ipv4_import
|
||||
|
||||
ipv4_export=
|
||||
if [ -f "${__object:?}"/parameter/ipv4-export ];
|
||||
then
|
||||
ipv4_export="$(cat "${__object:?}"/parameter/ipv4-export)"
|
||||
fi
|
||||
export ipv4_export
|
||||
|
||||
ipv6_import=
|
||||
if [ -f "${__object:?}"/parameter/ipv6-import ];
|
||||
then
|
||||
ipv6_import="$(cat "${__object:?}"/parameter/ipv6-import)"
|
||||
fi
|
||||
export ipv6_import
|
||||
|
||||
ipv6_export=
|
||||
if [ -f "${__object:?}"/parameter/ipv6-export ];
|
||||
then
|
||||
ipv6_export="$(cat "${__object:?}"/parameter/ipv6-export)"
|
||||
fi
|
||||
export ipv6_export
|
||||
|
||||
# Run template
|
||||
"${__type:?}"/files/template.sh > "${__files:?}/bgp-${__object_id:?}.conf"
|
||||
|
||||
# Install resulting configuration
|
||||
__file "${confdir:?}"/bgp-"${__object_id:?}".conf \
|
||||
--mode 0640 --owner root --group bird \
|
||||
--source "${__files:?}/bgp-${__object_id:?}.conf"
|
3
type/__bird_bgp/parameter/boolean
Normal file
3
type/__bird_bgp/parameter/boolean
Normal file
|
@ -0,0 +1,3 @@
|
|||
direct
|
||||
ipv4-extended-next-hop
|
||||
ipv6-extended-next-hop
|
7
type/__bird_bgp/parameter/optional
Normal file
7
type/__bird_bgp/parameter/optional
Normal file
|
@ -0,0 +1,7 @@
|
|||
description
|
||||
ipv4-export
|
||||
ipv4-import
|
||||
ipv6-export
|
||||
ipv6-import
|
||||
local-ip
|
||||
password
|
3
type/__bird_bgp/parameter/required
Normal file
3
type/__bird_bgp/parameter/required
Normal file
|
@ -0,0 +1,3 @@
|
|||
local-as
|
||||
neighbor-as
|
||||
neighbor-ip
|
65
type/__bird_core/man.rst
Normal file
65
type/__bird_core/man.rst
Normal file
|
@ -0,0 +1,65 @@
|
|||
cdist-type__bird-core(7)
|
||||
========================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__bird-core - setup a skeleton bird configuration.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
The `bird`_ daemon is an internet routing daemon, running protocols such as
|
||||
OSPF and BGP. This type creates a skeleton configuration file suitable for
|
||||
running a no-op bird. It is then intended to be combined - and depended on - by
|
||||
types specific to the instances of the various protocols that bird should run.
|
||||
|
||||
.. _bird: https://bird.network.cz/
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
router-id
|
||||
This parameter follows the format of an IPv4 address, and will be used by
|
||||
bird as its router id. See `the documentation for router id`_.
|
||||
|
||||
.. _the documentation for router id: https://bird.network.cz/?get_doc&v=20&f=bird-3.html#opt-router-id
|
||||
|
||||
log-params
|
||||
|
||||
This parameter expects a string suitable to follow the `log` bird
|
||||
configuration key. If this parameter is not include, the value `syslog all`
|
||||
is used. See `the documentation for log`_.
|
||||
|
||||
.. _the documentation for log: https://bird.network.cz/?get_doc&v=20&f=bird-3.html#opt-log
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
__bird-core --router-id 198.51.100.4
|
||||
|
||||
require='__bird-core' __bird_bgp <...>
|
||||
require='__bird-core' __bird_ospf <...>
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__bird_bgp(7)
|
||||
cdist-type__bird_filter(7)
|
||||
cdist-type__bird_kernel(7)
|
||||
cdist-type__bird_ospf(7)
|
||||
cdist-type__bird_static(7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2021 Joachim Desroches. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
72
type/__bird_core/manifest
Executable file
72
type/__bird_core/manifest
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2021 Joachim Desroches (joachim.desroches@epfl.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "${__global:?}/explorer/os")
|
||||
|
||||
package=
|
||||
conffile=
|
||||
confdir=
|
||||
case "$os" in
|
||||
"alpine")
|
||||
package=bird
|
||||
conffile=/etc/bird.conf
|
||||
confdir=/etc/bird.d
|
||||
;;
|
||||
*)
|
||||
printf "Your operating system (%s) is currently not supported by __bird_core\n" "$os" >&2
|
||||
printf "Please contribute an implementation for it if you can.\n" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
router_id=
|
||||
if [ -f "${__object:?}/parameter/router-id" ];
|
||||
then
|
||||
router_id="router id $(cat "${__object:?}"/parameter/router-id);"
|
||||
fi
|
||||
|
||||
log_params="syslog all"
|
||||
if [ -f "${__object:?}/parameter/log-params" ];
|
||||
then
|
||||
log_params="$(cat "${__object:?}"/parameter/log-params)"
|
||||
fi
|
||||
|
||||
__package "$package"
|
||||
|
||||
__directory "$confdir"
|
||||
|
||||
__file "$conffile" \
|
||||
--mode 0640 --owner root --group bird \
|
||||
--source - << EOF
|
||||
# $conffile - bird(1) configuration file.
|
||||
# Managed by cdist. Do not edit by hand.
|
||||
|
||||
${router_id}
|
||||
log ${log_params};
|
||||
|
||||
# Always include this "protocol": all it does is expose the available
|
||||
# interfaces to bird.
|
||||
protocol device {
|
||||
description "Obtain a list of device interfaces.";
|
||||
}
|
||||
|
||||
include "$confdir/*.conf";
|
||||
EOF
|
1
type/__bird_core/parameter/optional
Normal file
1
type/__bird_core/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
log-params
|
1
type/__bird_core/parameter/required
Normal file
1
type/__bird_core/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
router-id
|
0
type/__bird_core/singleton
Normal file
0
type/__bird_core/singleton
Normal file
63
type/__bird_filter/man.rst
Normal file
63
type/__bird_filter/man.rst
Normal file
|
@ -0,0 +1,63 @@
|
|||
cdist-type__bird_filter(7)
|
||||
==========================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__bird_filter - Create a named filter to use in configuring bird.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This type writes a configuration file defining a filter named `__object_id` for
|
||||
the bird internet routing daemon. It is guaranteed that all filters defined
|
||||
through this type will be loaded before any other protocol defined using the
|
||||
cdist __bird_xxx types, except functions. However, note that if two filters
|
||||
have a dependency, they will be loaded in alphabetical order, so some care may
|
||||
need to be taken in the naming.
|
||||
|
||||
This type takes it's input through stdin, expecting valid filter statements as
|
||||
per the bird configuration file syntax. The standard input will be printed out
|
||||
between a `filter __object_id {\n ... \n}`, so only the inner statements are
|
||||
needed.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Setup bird, a filter and open a BGP session.
|
||||
__bird_core --router-id 198.51.100.4
|
||||
|
||||
require='__bird_core' __bird_filter bgp_export <<- EOF
|
||||
if (source = RTS_DEVICE) then accept;
|
||||
reject;
|
||||
EOF
|
||||
|
||||
require='__bird_core' __bird_bgp bgp4 \
|
||||
--description "a test IPv4 BGP instance" \
|
||||
--ipv4-export "filter bgp_export" \
|
||||
--[...]
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__bird_core(7)
|
||||
cdist-type__bird_bgp(7)
|
||||
cdist-type__bird_function(7)
|
||||
cdist-type__bird_kernel(7)
|
||||
cdist-type__bird_ospf(7)
|
||||
cdist-type__bird_static(7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2021 Joachim Desroches. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
44
type/__bird_filter/manifest
Executable file
44
type/__bird_filter/manifest
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2021 Joachim Desroches (joachim.desroches@epfl.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "${__global:?}/explorer/os")
|
||||
|
||||
case "$os" in
|
||||
'alpine'|'debian'|'ubuntu')
|
||||
confdir=/etc/bird.d
|
||||
;;
|
||||
*)
|
||||
printf "Your operating system (%s) is currently not supported by __bird_filter\n" "$os" >&2
|
||||
printf "Please contribute an implementation for it if you can.\n" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Filters start with 1 because bird loads the config in alphanumerical order
|
||||
# and we need them to be defined to be used in the rest of the stuff, but after
|
||||
# functions.
|
||||
__file "$confdir/1-filter-${__object_id:?}.conf" \
|
||||
--owner root --group bird --mode 0640 \
|
||||
--source - << EOF
|
||||
filter ${__object_id:?} {
|
||||
$(cat "${__object:?}"/stdin)
|
||||
}
|
||||
EOF
|
58
type/__bird_function/man.rst
Normal file
58
type/__bird_function/man.rst
Normal file
|
@ -0,0 +1,58 @@
|
|||
cdist-type__bird_function(7)
|
||||
============================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__bird_function - Create a named function to use in configuring bird.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
This type writes a configuration file for the bird internet routing daemon. It
|
||||
is guaranteed that all functions defined through this type will be loaded
|
||||
before any other protocol defined using the cdist __bird_xxx types. However,
|
||||
note that if two functions have a dependency, they will be loaded in
|
||||
alphabetical order, so some care may need to be taken in the naming.
|
||||
|
||||
This type takes it's input through stdin, expecting a valid function definition
|
||||
as per the bird configuration file syntax.
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Setup bird, a function and open a BGP session.
|
||||
__bird_core --router-id 198.51.100.4
|
||||
|
||||
require='__bird_core' __bird_function is_device <<- EOF
|
||||
function is_device (enum source)
|
||||
{
|
||||
if (source = RTS_DEVICE) then return true;
|
||||
return false;
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__bird_core(7)
|
||||
cdist-type__bird_bgp(7)
|
||||
cdist-type__bird_filter(7)
|
||||
cdist-type__bird_kernel(7)
|
||||
cdist-type__bird_ospf(7)
|
||||
cdist-type__bird_static(7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2021 Joachim Desroches. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
41
type/__bird_function/manifest
Executable file
41
type/__bird_function/manifest
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2021 Joachim Desroches (joachim.desroches@epfl.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "${__global:?}/explorer/os")
|
||||
|
||||
case "$os" in
|
||||
'alpine'|'debian'|'ubuntu')
|
||||
confdir=/etc/bird.d
|
||||
;;
|
||||
*)
|
||||
printf "Your operating system (%s) is currently not supported by __bird_filter\n" "$os" >&2
|
||||
printf "Please contribute an implementation for it if you can.\n" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Functions start with 0 because bird loads the config in alphanumerical order
|
||||
# and we need them to be defined to be used in the rest of the stuff.
|
||||
__file "$confdir/0-function-${__object_id:?}.conf" \
|
||||
--owner root --group bird --mode 0640 \
|
||||
--source - << EOF
|
||||
$(cat "${__object:?}"/stdin)
|
||||
EOF
|
73
type/__bird_kernel/man.rst
Normal file
73
type/__bird_kernel/man.rst
Normal file
|
@ -0,0 +1,73 @@
|
|||
cdist-type__bird_kernel(7)
|
||||
==========================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__bird_kernel - configure syncing of routes with the kernel.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
This type writes the configuration for an instance of the kernel protocol to be
|
||||
ran by the bird internet routing daemon. It **expects** to depend on the
|
||||
`cdist-type__bird_core(7)` type.
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
description
|
||||
An instance desciption to be printed when `birdc show protocols` is called.
|
||||
|
||||
persist
|
||||
Instruct bird to leave routes in kernel table after exiting. See the bird
|
||||
`persist` keyword.
|
||||
|
||||
learn
|
||||
Learn routes added externally to the kernel routing table. See the bird
|
||||
`learn` keyword.
|
||||
|
||||
channel
|
||||
The channel to connect the protocol to. Usually `ipv4` or `ipv6`.
|
||||
|
||||
import
|
||||
A string suitable for the bird `import` directive. Usually `all`, `none` or
|
||||
a filter definition.
|
||||
|
||||
export
|
||||
See import.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Setup bird and open a BGP session.
|
||||
__bird_core --router-id 198.51.100.4
|
||||
|
||||
require='__bird_core' __bird_kernel k4 \
|
||||
--learn --persist --channel ipv4 \
|
||||
--import all \
|
||||
--export all
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__bird_bgp(7)
|
||||
cdist-type__bird_core(7)
|
||||
cdist-type__bird_filter(7)
|
||||
cdist-type__bird_ospf(7)
|
||||
cdist-type__bird_static(7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2021 Joachim Desroches. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
83
type/__bird_kernel/manifest
Executable file
83
type/__bird_kernel/manifest
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2021 Joachim Desroches (joachim.desroches@epfl.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "${__global:?}/explorer/os")
|
||||
|
||||
case "$os" in
|
||||
"alpine"|"debian"|"ubuntu")
|
||||
confdir="/etc/bird.d"
|
||||
;;
|
||||
*)
|
||||
printf "Your operating system (%s) is currently not supported by __bird_kernel\n" "$os" >&2
|
||||
printf "Please contribute an implementation for it if you can.\n" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Required parameters
|
||||
channel="$(cat "${__object:?}/parameter/channel")"
|
||||
|
||||
# Boolean switches
|
||||
persist=
|
||||
if [ -f "${__object:?}"/parameter/persist ];
|
||||
then
|
||||
persist=true
|
||||
fi
|
||||
|
||||
learn=
|
||||
if [ -f "${__object:?}"/parameter/learn ];
|
||||
then
|
||||
learn=true
|
||||
fi
|
||||
|
||||
# Optional parameters
|
||||
description=
|
||||
if [ -f "${__object:?}"/parameter/description ];
|
||||
then
|
||||
description="$(cat "${__object:?}/parameter/description")"
|
||||
fi
|
||||
|
||||
import=
|
||||
if [ -f "${__object:?}"/parameter/import ];
|
||||
then
|
||||
import="$(cat "${__object:?}/parameter/import")"
|
||||
fi
|
||||
|
||||
_export=
|
||||
if [ -f "${__object:?}"/parameter/export ];
|
||||
then
|
||||
_export="$(cat "${__object:?}/parameter/export")"
|
||||
fi
|
||||
|
||||
# Install resulting configuration
|
||||
__file "${confdir:?}"/kernel-"${__object_id:?}".conf \
|
||||
--mode 0640 --owner root --group bird \
|
||||
--source - << EOF
|
||||
protocol kernel ${__object_id:?} {
|
||||
$([ -n "${description?}" ] && printf "\tdescription \"%s\";\n" "${description?}")
|
||||
$([ -n "${persist?}" ] && printf "\tpersist;\n")
|
||||
$([ -n "${learn?}" ] && printf "\tlearn;\n")
|
||||
${channel:?} {
|
||||
import ${import:?};
|
||||
export ${_export:?};
|
||||
};
|
||||
}
|
||||
EOF
|
2
type/__bird_kernel/parameter/boolean
Normal file
2
type/__bird_kernel/parameter/boolean
Normal file
|
@ -0,0 +1,2 @@
|
|||
learn
|
||||
persist
|
1
type/__bird_kernel/parameter/optional
Normal file
1
type/__bird_kernel/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
description
|
3
type/__bird_kernel/parameter/required
Normal file
3
type/__bird_kernel/parameter/required
Normal file
|
@ -0,0 +1,3 @@
|
|||
channel
|
||||
import
|
||||
export
|
56
type/__bird_ospf/man.rst
Normal file
56
type/__bird_ospf/man.rst
Normal file
|
@ -0,0 +1,56 @@
|
|||
cdist-type__bird-ospf(7)
|
||||
========================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__bird-ospf - Configure an instance of the OSPF protocol
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
This type is an *extremely rudimentary* method to configure a simple OSPF
|
||||
protocol instance for bird, the internet routing daemon. Even this manpage is
|
||||
pretty crude and will be fixed and expanded.
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
channel
|
||||
The channel the protocol should connect to. Usually `ipv4` or `ipv6`.
|
||||
|
||||
import
|
||||
The keyword or filter to decide what to import in the above channel.
|
||||
|
||||
export
|
||||
The keyword or filter to decide what to export in the above channel.
|
||||
|
||||
|
||||
REQUIRED MULTIPLE PARAMETERS
|
||||
----------------------------
|
||||
interface
|
||||
An interface to include in OSPF area 0.
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
description
|
||||
A description given with `show protocol all`
|
||||
|
||||
instance-id
|
||||
An OSPF instance ID, allowing several OSPF instances to run on the same
|
||||
links.
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__bird_core(7)
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2021 Joachim Desroches. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
63
type/__bird_ospf/manifest
Executable file
63
type/__bird_ospf/manifest
Executable file
|
@ -0,0 +1,63 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2021 Joachim Desroches (joachim.desroches@epfl.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "${__global:?}/explorer/os")
|
||||
|
||||
case "$os" in
|
||||
'alpine'|'debian'|'ubuntu')
|
||||
confdir='/etc/bird.d'
|
||||
;;
|
||||
*)
|
||||
printf "Your operating system (%s) is currently not supported by this __bird_ospf\n" "$os" >&2
|
||||
printf "Please contribute an implementation for it if you can.\n" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
description=
|
||||
if [ -f "${__object:?}/parameter/description" ];
|
||||
then
|
||||
description="$(cat "${__object:?}/parameter/description")"
|
||||
fi
|
||||
|
||||
instance_id=
|
||||
if [ -f "${__object:?}/parameter/instance-id" ];
|
||||
then
|
||||
instance_id="$(cat "${__object:?}/parameter/instance-id")"
|
||||
fi
|
||||
|
||||
__file "${confdir:?}/ospf-${__object_id:?}.conf" \
|
||||
--mode 0640 --owner root --group bird \
|
||||
--source - << EOF
|
||||
protocol ospf v3 ${__object_id:?} {
|
||||
$([ -n "${description?}" ] && printf "\tdescription \"%s\";\n" "${description?}")
|
||||
$([ -n "${instance_id?}" ] && printf "\tinstance id %s;\n" "${instance_id?}")
|
||||
|
||||
$(cat "${__object:?}/parameter/channel") {
|
||||
import $(cat "${__object:?}/parameter/import");
|
||||
export $(cat "${__object:?}/parameter/export");
|
||||
};
|
||||
|
||||
area 0 {
|
||||
$(sed -e 's/^/\t\tinterface "/' -e 's/$/";/' "${__object:?}/parameter/interface")
|
||||
};
|
||||
}
|
||||
EOF
|
2
type/__bird_ospf/parameter/optional
Normal file
2
type/__bird_ospf/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
|||
description
|
||||
instance-id
|
3
type/__bird_ospf/parameter/required
Normal file
3
type/__bird_ospf/parameter/required
Normal file
|
@ -0,0 +1,3 @@
|
|||
channel
|
||||
import
|
||||
export
|
1
type/__bird_ospf/parameter/required_multiple
Normal file
1
type/__bird_ospf/parameter/required_multiple
Normal file
|
@ -0,0 +1 @@
|
|||
interface
|
30
type/__bird_static/files/template.sh
Executable file
30
type/__bird_static/files/template.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
# Template to generate a static protocol configuration file for bird(1).
|
||||
# Required non-empty variables:
|
||||
# __object_id, object
|
||||
#
|
||||
# Required defined variables:
|
||||
# description
|
||||
|
||||
# Header
|
||||
printf "protocol static %s {\n" "${__object_id:?}"
|
||||
|
||||
# Optional description
|
||||
[ -n "${description?}" ] && printf "\tdescription \"%s\";\n" "${description:?}"
|
||||
|
||||
# Channel choice
|
||||
if [ -f "${__object:?}/parameter/ipv4" ];
|
||||
then
|
||||
printf "\tipv4;\n"
|
||||
else
|
||||
printf "\tipv6;\n"
|
||||
fi
|
||||
|
||||
# Routes
|
||||
while read -r route
|
||||
do
|
||||
printf "\troute %s;\n" "${route?}"
|
||||
done < "${__object:?}/parameter/route"
|
||||
|
||||
# Header close
|
||||
printf "}\n"
|
69
type/__bird_static/man.rst
Normal file
69
type/__bird_static/man.rst
Normal file
|
@ -0,0 +1,69 @@
|
|||
cdist-type__bird_static(7)
|
||||
==========================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__bird_static - configure an instance of the bird static protocol.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This type write the configuration file for an instance of the static protocl to
|
||||
be ran bu the bird internet routing daemon, allowing an administrator to inject
|
||||
static routes into the daemon's routing tables. This protocol allows for only
|
||||
one of two channels to be used, either `ipv4` or `ipv6`, by default `ipv6` is
|
||||
used unless the `ipv4` flag is passed. This type **expects** to depend on the
|
||||
`cdist-type__bird_core(7)` type.
|
||||
|
||||
|
||||
REQUIRED MULTIPLE PARAMETERS
|
||||
----------------------------
|
||||
route
|
||||
This flag expects a valid route to be inserted between the bird `route`
|
||||
keyword and the end of line. It may be specified as many times as necessary.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
description
|
||||
An instance desciption to be printed when `birdc show protocols` is called.
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
ipv4
|
||||
Use the ipv4 channel instead of the default ipv6 one.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Setup bird and open a BGP session.
|
||||
__bird_core --router-id 198.51.100.4
|
||||
|
||||
require='__bird_core' __bird_static static4 \
|
||||
--description "static ipv4 routes plugged into bird" \
|
||||
--route "198.51.0.0/16 via 192.51.100.1" \
|
||||
--route "192.52.0.0/16 via 192.51.100.1"
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__bird_core(7)
|
||||
cdist-type__bird_bgp(7)
|
||||
cdist-type__bird_kernel(7)
|
||||
cdist-type__bird_ospf(7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2021 Joachim Desroches. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
51
type/__bird_static/manifest
Executable file
51
type/__bird_static/manifest
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2021 Joachim Desroches (joachim.desroches@epfl.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "${__global:?}/explorer/os")
|
||||
|
||||
case "$os" in
|
||||
'alpine'|'debian'|'ubuntu')
|
||||
confdir=/etc/bird.d
|
||||
;;
|
||||
*)
|
||||
printf "Your operating system (%s) is currently not supported by __bird_static\n" "$os" >&2
|
||||
printf "Please contribute an implementation for it if you can.\n" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Required parameter route is directly accessed in template.
|
||||
# Boolean parameter ipv4 is directly accessed in template.
|
||||
# Optional parameter description
|
||||
description=
|
||||
if [ -f "${__object:?}/parameter/description" ];
|
||||
then
|
||||
description="$(cat "${__object:?}/parameter/description")"
|
||||
fi
|
||||
export description
|
||||
|
||||
# Run template
|
||||
"${__type:?}"/files/template.sh > "${__files:?}/static-${__object_id:?}.conf"
|
||||
|
||||
# Install resulting configuration
|
||||
__file "${confdir:?}"/static-"${__object_id:?}".conf \
|
||||
--mode 0640 --owner root --group bird \
|
||||
--source "${__files:?}/static-${__object_id:?}.conf"
|
1
type/__bird_static/parameter/boolean
Normal file
1
type/__bird_static/parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
|||
ipv4
|
1
type/__bird_static/parameter/optional
Normal file
1
type/__bird_static/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
description
|
1
type/__bird_static/parameter/required_multiple
Normal file
1
type/__bird_static/parameter/required_multiple
Normal file
|
@ -0,0 +1 @@
|
|||
route
|
Loading…
Reference in a new issue