Before running «systemctl preset-all» we remove all .wants dependency
directories, because otherwise the preset-all command leaves obsolete
files behind. But «systemctl preset-all» fails if there's any broken
service symlink around, which means we end up with no dependency
information whatsoever implying a severely broken system, that in
addition is then unbootable.
Remove any such broken symlinks before calling «systemctl preset-all».
Change-Id: I58fe650cb04ddb140922563169a7fedb09a8ceac
As reported at https://jenkins.mgm.sipwise.com/job/ngcpcfg-tap-test/4544/
when building against Debian/trixie
Furthermore fix SC2166 + SC2086 issues within helper/check-for-mysql
as reported by manual shellcheck v0.10.0 runs.
Change-Id: Ic9be0dbc8ef4a501cf3b6e62522574da72f85c99
* $NGCP_TYPE is unset on SPCE by default, add checks for $NGCP_TYPE
being unset and load it manually for such cases as it should be
present on all NGCP platforms.
Change-Id: I5a8fafd1a376fadb2e15aa96db8d473d65b212d7
* on carrier proxy nodes ngcp-sync-db-grants and ngcp-sync-db-creds
are now also invoked for 127.0.0.1:3308 instance because
table grants and user credentials are not replicated by default
* change "Synchronizing MySQL grants/credentials" log string to
"Synchronizing MariaDB grants/credentials" to better reflect that
MariaDB is used as the database
Change-Id: Ie4e77147621df34fc4e7f0e333183fb3b313f260
We move some of the OpenPGP support into this file, which we will extend
once we switch to use the OpenPGP Stateless OpenPGP support.
Change-Id: I56acd993cb394dd8bc12a8da3cf4c78088adb61b
We can simply feed the encrypted or unencrypted tarfile both when
decrypting and encrypting it, so that we do not have to leave one
around with the additional disk space, and danger of it not getting
removed.
Change-Id: If8c9fba36fd14c58cccacc789a0e4f8e474aac3f
Rename gpg to pgp or OpenPGP and remove crypted from filenames.
The standard is called OpenPGP, GnuPG (or GPG, gpg) is one of many
implementations (although depending on the context the prevalent one)
so we use that when referring to the specification.
For the encrypted tarball we remove the «-crypted» term which is an
odd wording use for encryted content and it is unnecessary and confusing
when using layered containers (as when the tarball is decrypted the
name becomes invalid); and make it use «.pgp» instead of «.gpg» as
extension, while trying the old filename on decryption for backwards
compatibility.
Change-Id: If5e0349ff0c3d8e3b47ced361e9e77d7d4d2defc
These functions were previously in the main functions file, which we
could not use as it depends on configuration files we do not have
available while decrypting these same configurations. But these got
split up for performance reasons into its own functions file. We can
thus now switch to use that instead of having to keep the same functions
in sync in multiple places.
Change-Id: I3860d747e575146d4ffc1a6fc8160d7aa16925ed
When doing an «ngcpcfg apply» we are required to pass a reason for it
which might be included in a «git commit», but not in the etckeeper
commit. Modify the wording for the latter, and include that reason so
that the git history makes more sense and is more traceable.
So when executing:
# ngcpcfg apply "Fix array in component B"
The git commit message looked before like:
ngcpcfg apply
And now it will look like
Fix array in component B via "ngcpcfg apply"
Change-Id: Ib7b4ce986366ca51a487a087cb327b0d0dfe1ccd
The date is already tracked as part of the commit metadata, and we use
the current day which will always match the author date for the commit,
so no information is lost.
This makes the commit message more clear and removes redundant and
distracting information from it.
For «ngcpcfg log» we include the date from the commit metadata explicitly
in the output, which will be duplicated for old entries but gets it from
where it belongs for new ones. (Even though the date is also printed in
relative terms on the front of the line.) We now get this output for old
and new entries:
* b3767f6 (10 hours ago) new [2024-02-02 14:28:11 +0100] (HEAD -> master)
* dc0a310 (3 days ago) old [2024-01-30 23:10:32.674452749+01:00] [2024-01-30 23:10:32 +0100]
Change-Id: I4eb4faed433db52e6755bc7782ec34545741d452
We are prepending an extra / to the pathnames passed to tar, and
calling tar from a directory other than the root directory while
not telling it to use absolute names so it complains about these
two things with the following messages:
,---
tar: Removing leading `/' from member names
tar: Removing leading `/' from hard link targets
tar: Removing leading `//' from member names
tar: Removing leading `//' from hard link targets
`---
which is something the user cannot do much about, and it's rather
annoying.
Change-Id: I9e9c853f26363e451b8883d3c74c5508ba3049dc
* sync_extra_sockets() renamed into sync_lb_and_extra_sockets()
* extra_sockets_sync() renamed into lb_and_extra_sockets_sync()
* $config now also contains merged $NETWORK_CONFIG (network.yml)
* lb_and_extra_sockets_sync does the following and then calls
generic_enum_sync() to provide with the gathered data:
* all shared ips from interfaces that
- host have 'lb' role
- host status 'online'
- interface has type '^sip_'
are added into the outbound sockets list of protos (udp, tcp, tls)
as: 'host:interface:proto' = 'proto:shared_ip:port'
(port is taken from config.kamailio.lb.port in case of ('udp', 'tcp')
and config.kamailio.tls.port in case of 'tls'
)
- if an interface has multiple shared IPs,
the key becomes 'host:interface:shared_ip:proto'
- $config->{kamailio}{lb}{extra_sockets} keys are merged
with the gathered config
* generic_enum_sync() - processes hash keys are now sorted
to have consistent output/processing
Change-Id: I218f1ae584e2dc9dfeb3a51c43d9f3fc950e829b
We check whether we have both a sites.yml and a sites/ directory.
If so, and multi-sites support is enabled, then we proceed to load
all the multi-sites configurations, by placing each of them under
«sites.<site-name>.<config>». Adding a «sites.current» link to the
current site, and filling the root tree config with the current site
as well for backwards compatibility.
Change-Id: Ia810f57e8e976eef6a7582bddda46c1701456ed6
For multi-site support we need to pass all the possible files to load,
and these might be different between sites, so we need to check for
their existence from within tt2-process, instead of from the outside as
that would restrict them to only the current site.
Change-Id: I0965506832aa2f0a1ba67b19511c509bec60922e
The script got supported added for the maintenance file, but missed a
spot where the actual selection is performed.
Fixes: commit 948f940975
Change-Id: I9d092fd99a821f6f8ce72b0f7b8c05e5ab1c25e6
We need to pass the host lists to the check remote code, and we should
not be passing any host lists to the check shared storage code, as that
takes an action instead.
Change-Id: I7292cf56f110df81f5a3b83da911742bae2af1b2
Fixing issues reported by new shellcheck v0.9.0:
1) SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
https://www.shellcheck.net/wiki/SC2317
(new feature as of shellcheck v0.9.0)
2) SC2086 (info): Double quote to prevent globbing and word splitting.
https://www.shellcheck.net/wiki/SC2086
(behavior change with shellcheck v0.9.0)
Change-Id: I73d50157f72b772c381cf1bff497079133bc6d09
These commands are db-specific, and the constants one involves the
database credentials, so give both better names to make it clear these
are not general purpose commands.
Preserve backwards compatibility symlinks for external callers, or
user muscle memory, which this gets migrated away.
Change-Id: I3baae364e786ebbdc9e386dfc4f8c0bf54333cd1
Move perl code which actually modifies yml file to separate helper as
there is no sense to recreate it every call of 'ngcpcfg del'.
Change-Id: Iab9e023318cf9798bdb10d89b08dc2afe125c495
In ngcp-initial-configuration there are a lot of multiple sequential calls
of 'ngcpcfg set' which consume significant amount of time.
So add support for setting multiple options to do it at once.
Change-Id: I8cacdbec78ecefc4681048a0fb085b4cb705d83e
Move perl code which actually modifies yml file to separate helper as
there is no sense to recreate it every call of 'ngcpcfg set'.
Change-Id: I08b10186b1aa127d4a2b81ef36b234dfdd46fc8e
If the maintenance mode is enabled, then we shouldn't suggest to
run ngcpcfg build/apply, as this might cause unexpected side effects.
Instead report that the maintenance mode is enabled and we're skipping
checks.
Change-Id: I2ca43142a3caeac2c00514b1353568f4c438fbed
Introduce a list of checks related to connections:
* check that we don't have instance names duplicates
* prove an existence of a preferred for instnace host
* an instance to which instance gets connected exists
* a host to which instance gets connected exists
* interface via which instance gets connected is defined
Change-Id: I24f43b0fb24e308f571a88f30a72a9b6dd04b94d
We add support for YAML schemas, and hook it into the check command to
validate the sites.yml file.
Change-Id: Ic6ed43e36361d395b485230af4ec3cf7e77758bb
we can define what is the expected origin via
/etc/ngcp-ngcpcfg/ngcpcfg.d/mgmnode.cfg for instance
Change-Id: Ied83502ddc022a1c7bb948f43bee7ccc10efcd88
This off-loads the check to the ngcp-site script, and prints any error
message from it if the script fails.
Only run the check if ngcp-site is present, so that we avoid a
hard-dependency on system-tools.
Change-Id: I640f85383d424980d81a207dee7d586a88422862
This is the symlink pointing to the current site for this site, which
cannot be committed to git, or we'd get constant conflicts when multiple
sites commit their own.
Change-Id: I054afc15bb3a52d0ca2357db5ea4a152cfff035b
This special handling was from a time when we did not have any other
generic suffix support to override based on hostname, nodename, role,
etc. It also depends on the now obsolete systems.cfg file which is
redundant and already covered by the information contained in
network.yml.
Our tt2-process tool already handles these suffixes, so there is no
point in special-casing them from within the build script. This way we
simplify our templating and overriding mechanism, and reduce duplication
of information.
Change-Id: Iabf597dbaddf755a7f85504975afc8666a58d272
We want to be able to track down any left-behind tmp files,
so ensure we're creating them with according file names.
Change-Id: I1aa0ccdb8834e8aef919f1f028028c1bb14cbd01
The HA_NODE, HA_FILE and HA_CONFIG variables and nomenclature are
deprecated in favor of the NGCP_NODENAME, NODE_FILE and NODE_CONFIG.
Switch the old uses to the new ones. Unify PAIRNAME to NGCP_PAIRNAME.
Leave the old HA_ variables for backwards compatibility
Change-Id: I11f09f1620c2e456f10fc17229b61ec5a35a732b
We should validate all configuration files by concatenating them, so
that any local addition or override gets schema validated, otherwise
these modifications will pass without notice, until it is probably too
late.
Change-Id: I9c7774eefdeadddb399dd68668779dffcd173696
This new action concatenates the various configuration files and outputs
the result as YAML. This is useful because they have a determined
ordering, and include optional host specific files that might not be
obvious how to merge.
This will also be the foundation for verifying all the current host
settings against the cfg-schema.
Change-Id: I72a61193f74caf3b2f7a58a47eefad2ed46c973a
Otherwise 'ngcpcfg apply' silently aborted on stage 'build'
and error message is not visible due to long/parallel output.
Change-Id: I34b2c14fecad33526d89939e62d85dbafab31535
* We were missing the scenario when only the build files for an instance
had changes. The service for that instance was not restarted
Change-Id: I85ba86bc57c7fc8b6df1ac2ef1144c2d3952a4da
The prevalent convention in the project is to use «-» instead of «_» to
split words in options. Switch the options to that, and keep backwards
compatibility option alias that emits a deprecation warning while people
transition to the new names. The alias will be removed on the next LTS.
Change-Id: I8bb7f26f8a766f7ea76ba2d9e49b793e5cb8d11e
Instead of having to identify the parent process name (ngcpcfg vs.
ngcp-config) inside subprocesses (like "status"), let's provide the
invocation name through the main ngcpcfg binary via variable
NGCPCFG_NAME.
Thanks to Guillem Jover for the suggestion.
Change-Id: Iafbac535bedb9cc9dc73f3d95861a5bc735cc739
will provide a new instance_info variable with the all the content
defined at network.yml for the instance
removed intance_name since instance_info.name has the same value
Change-Id: I349d0b430b59280bc383d46d5ba6a61f5d1f9046
When invoking `ngcp-config status`, we reported "ngcpcfg":
| [sipwise-lab-trunk] sipwise@sp1:~$ sudo ngcpcfg status
| 2021-12-09 17:30:08 sp1: Checking state of ngcpcfg:
| 2021-12-09 17:30:08 sp1: OK: has been initialised already
| [...]
While what we should report instead is "ngcpcfg-config", like:
| [sipwise-lab-trunk] sipwise@sp1:~$ sudo ngcp-config status
| 2021-12-09 17:31:31 sp1: Checking state of ngcp-config:
| 2021-12-09 17:31:31 sp1: OK: has been initialised already
| [...]
Change-Id: If8fc8076fdf1d214baea3c7388ab208947d66a05
The previous error message was really confusing:
> root@spce:~# ngcpcfg get /asdf
> 2021-12-06 18:48:12 sp1: Error: Cannot process template '/tmp/tmp.RBRJg02PEz':
>
> file error - parse error - input file handle line 1: unexpected token (/asdf)
> [% /asdf %]
> 2021-12-06 18:48:12 sp1: Error: Generating /tmp/tmp.NKfB8BtJXv based on /tmp/tmp.RBRJg02PEz: FAILED
It happens due to the way ngcpcfg using TT2 template which
is trying to include the file it the string looks like a PATH.
The new error message is more user friendly
(and generates proper/non-zero exit code):
> root@spce:~# ngcpcfg get /asdf
> 2021-12-07 12:42:50 spce: Error: cannot process request for '/asdf'!
> root@spce:~# echo $?
> 1
> root@spce:~#
Change-Id: Ifaf56dec07adf8600bd9d7cf2e733769d6d82a4f
* expects values from CONFIG_POOL
* append OUTPUT_DIRECTORY just when changing directory
added at 83003649e3
Change-Id: I9c22bff70b58d4cfb49c3dab45330bccb898011e
Switch all code to use a loop to parse options so that these can parse
multiple options (currently some scripts would simply parse one or
another but not several), and to make them easier to extend.
Change-Id: I5e902f2d7d8db78e66e48db1237924fa7d8fdda1
we need to produce different output for each instance defined
from the same source
* helper/instances-info, produces the needed output to feed
helper/tt2-process with the proper arguments to build
instances files. We inject ``instance_name`` with the
proper value to templates and INSTANCE_NAME to hooks
environment
* ${NGCPCTL_MAIN}/ngcpcfg.instances is where we define the
supported instance templates and where the output path is
* helper/tt2-process, add -r --replace <path:path> option
in order to allow generation of different output from
the same source
Change-Id: I067266b5226485ea0d6c3bc3436275c5553a8177