Makes run-cosmos request a fleetlock lock before running cosmos "update"
and "apply" steps. This is helpful for making sure only one (or several)
machine out of some set of machines runs cosmos changes at a time. This
way if cosmos (or puppet) decides that a service needs to be restarted
this will only happen on a subset of machines at a time. When the cosmos
"apply" is done a fleetlock unlock request will be performed so the
other machines can progress.
The unlock code in run-cosmos will also run the new tool
sunet-machine-healthy to decide things are good before unlocking. This
way if a restarted service breaks this will stop the unlock attempt
and in turn make it so the others should not break their service as
well, giving an operator time to figure out what is wrong.
The db-file, essentially providing reverse lookup of classes to host
names, is only used by some Nagios configuration instances and causes
continuing operational headaches in those ops-repos.
It should be kept/refactored to only apply to the monitoring hosts in
the cases where it is used, but we don't want any new ops-repos to use
it hence it should be removed from upstream multiverse.
We use the separator later on to determine where the yaml document starts.
`eyaml edit` adds the separator to new (non-existing) files by itself but
since we want to create the file before in order to diff later the separator
needs to be added in order to get a valid document.
* Only update cosmos-modules.conf if a change is needed
* Do an atomic replace of the file if updating it
* Add a note at the top mentioning that it is tool-generated
* Make pylint and black happy
Tested in ubuntu 18.04.
Fixes:
```
70run-post-tasks: invoking /var/cache/cosmos/model/post-tasks.d/018packages
Your configuration specifies to merge with the ref 'refs/heads/master'
from the remote, but no such ref was fetched.
```
Without this fix:
```
➜ nunoc-ops git:(master) make db
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
make: *** [db] Error 1
```
With this fix:
```
➜ swamid-ops git:(master) ✗ make db
make: Nothing to be done for `db'.
```
Will make it easier to only use `make tag` when to sign changes.
For CNaaS machines we supply cloud-init user-data that does not create a
default user, in this case the script would exit half-way through. Now
it only tries to remove a user if it exists in the first place.