* 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.
Before this change there was a need to keep addhost and
bootstrap-cosmos.sh in sync regarding what version of the cosmos deb to
scp over and later run.
Now we find the latest version as decided by `sort -V` in both addhost
and bootstrap-cosmos.sh.
Solution discussed with @fredrikt.
Now ubuntu also uses the updated way of preparing iaas instances like
debian did before, actually the debian scripts have been remade to also
handle ubuntu so we use a common code path.
Usage (what scripts to call) stay the same, but the underlying
operations takes less logins to complete.
Good idea to fail when unexpected things go wrong. Additional fixes
added to the script to not stop where we can expect a non-zero return
code.
Requested by @fredrikt who also reviewed the patch before going in,
thanks!
* Log in as few times as possible to not require a lot if yubikey
keypresses
* Make sure en_US.UTF-8 is present
* Replace `rm -rf` with userdel command
* Make sure the debian account is actually deleted
* Remove locale related warnings when running script from macOS