Closed deepfire closed 4 years ago
It is possible to rename deployments using 'modify' sub-command and the -n option
Help Menu
$ nixops modify --help
usage: nixops modify [-h] [--state FILE] [--deployment UUID_OR_NAME] [--debug]
[--confirm] [-I PATH] [--max-jobs N] [--cores N]
[--keep-going] [--keep-failed] [--show-trace]
[--fallback] [--no-build-output] [--option NAME VALUE]
[--read-only-mode] [--name NAME] [--template TEMPLATE]
[NIX-FILE [NIX-FILE ...]]
..
..
..
--name NAME, -n NAME new symbolic name of deployment
Code :
Example List the deployments
$ nixops list
+--------------------------------------+---------------------+------------------------+------------+------+
| UUID | Name | Description | # Machines | Type |
+--------------------------------------+---------------------+------------------------+------------+------+
| a71b3f0c-9178-11ea-86f7-f430b9cbe870 | deployment | Unnamed NixOps network | 0 | |
| bc593b42-9181-11ea-8e03-f430b9cbe870 | old-deployment-name | Unnamed NixOps network | 0 | |
+--------------------------------------+---------------------+------------------------+------------+------+
Check the nix expressions and path of the deployment "old-deployment-name"
$ nixops info -d old-deployment-name
Network name: old-deployment-name
Network UUID: bc593b42-9181-11ea-8e03-f430b9cbe870
Network description: Unnamed NixOps network
Nix expressions: /examples/network.nix
Nix path: -I keys=/data/keys
Nix arguments: token = "<keys/token>"
+-------------------------+---------+-------------------+-------------+------------+
| Name | Status | Type | Resource Id | IP address |
+-------------------------+---------+-------------------+-------------+------------+
| first-sample-dashboard | Missing | grafana-dashboard | | |
| parent-folder | Missing | grafana-folder | | |
+-------------------------+---------+-------------------+-------------+------------+
Modify that deployment while specifying all nix inputs
nixops modify -d bc593b42-9181-11ea-8e03-f430b9cbe870 \
/examples/network.nix \
-I keys=/data/keys \
-n new-deployment-name
$ nixops list
+--------------------------------------+---------------------+------------------------+------------+------+
| UUID | Name | Description | # Machines | Type |
+--------------------------------------+---------------------+------------------------+------------+------+
| a71b3f0c-9178-11ea-86f7-f430b9cbe870 | deployment | Unnamed NixOps network | 0 | |
| bc593b42-9181-11ea-8e03-f430b9cbe870 | new-deployment-name | Unnamed NixOps network | 0 | |
+--------------------------------------+---------------------+------------------------+------------+------+
Thank you a lot, @tewfik-ghariani, that works indeed!
~Currently deployments cannot be renamed.~
This complicates their management, if you have a bunch of those, and the initial choice of their names isn't matching changed requirements.