forked from YesSeri/hostmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Exclude dry activate #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mran-dbc
wants to merge
6
commits into
master
Choose a base branch
from
exclude-dry-activate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c0d1728
Fixes to make a newly started development env. work
mran-dbc d052476
direnv and gitignore
mran-dbc a5a88ad
Added options to run the server
mran-dbc 337eeb0
Updated README. Slightly better log messages
mran-dbc 6fd8284
Filter out dry-activate from overview
mran-dbc c467c3a
Removed references to DBC
mran-dbc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| if nix flake show &> /dev/null; then | ||
| echo "-----------------------------------------" | ||
| echo "Launching DevShell (flake)" | ||
| echo "-----------------------------------------" | ||
| use flake . | ||
| else | ||
| echo "---------------------------------------------" | ||
| echo "Launching DevShell (nix-shell)" | ||
| echo "---------------------------------------------" | ||
| use nix | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,24 @@ | ||
| /target | ||
| /pg | ||
| /.env | ||
| /postgres.log | ||
| /.pre-commit-config.yaml | ||
| /result | ||
| /.dev_postgres | ||
| /setup.sh | ||
|
|
||
| # Dev dir's | ||
| /postgres.log | ||
| /.dev_postgres | ||
|
|
||
| # ide's | ||
| /.idea | ||
| /.vscode | ||
|
|
||
| # Temps | ||
| /scratch.sql | ||
| /api-key.txt | ||
| /test-assets/ | ||
| todo.md | ||
|
|
||
| # direnv | ||
| .direnv/* | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,127 @@ | ||
| # | ||
| run like this | ||
| # Project overview | ||
| HostMap is a set of tools used to track what is installed on machines managed by *Platform*.\ | ||
| It consists of: | ||
| 1. One or more servers running a web-server and a database hosting the data and overview. | ||
| 2. A wrapper around the `switch-to-configuration` script on each managed host.\ | ||
| The wrapper script is logging information about each activation -- Timestamp, username, the store path and action taken. | ||
| 3. An activation-logger running on each managed host, which can serve the collected activations. | ||
| 4. A scraper running on the HostMap servers will contact each Nix-host in the configuration and fetch the list and post it to the web server where it is stored in the database. | ||
| 5. A `hostmap-update` script running on the build server that will save information about the building of hostname, git commit hashes, branch name, store path and a timestamp. | ||
| The files generated by `hostmap-update` is transferred to the hostmap web server | ||
|
|
||
| ## Host configuration example: | ||
| ```json | ||
| [ | ||
| { | ||
| "hostname": "gitlab-t01", | ||
| "host_url": "gitlab-t01.pzz.dk", | ||
| "metadata": { | ||
| "env": "stg", | ||
| "host_group_name": "hosts-prod" | ||
| } | ||
| }, | ||
| { | ||
| "hostname": "gitlab-p01", | ||
| "host_url": "gitlab-p01.pzz.dk", | ||
| "metadata": { | ||
| "env": "stg", | ||
| "host_group_name": "hosts-prod" | ||
| } | ||
| }, | ||
| { | ||
| "hostname": "localhost", | ||
| "host_url": "localhost", | ||
| "metadata": { | ||
| "env": "stg", | ||
| "host_group_name": "hosts-prod" | ||
| } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| ## Scraped file Example: | ||
| ```csv | ||
| 2026-04-13 09:31:04+02:00;srhb;/nix/store/r1d177x9dan0jgj0280w75li5fqlpp8w-nixos-system-hosts-p03-25.11pre-git;boot | ||
| 2026-04-21 12:07:42+02:00;mran;/nix/store/wc8sgkdad9wnb2q9bds5mlsfy7999990-nixos-system-hosts-p03-25.11pre-git;switch | ||
| 2026-04-22 09:31:04+02:00;srhb;/nix/store/r1d177x9dan0jgj0280w75li5f999991-nixos-system-hosts-p03-25.11pre-git;dry-activate | ||
| ``` | ||
|
|
||
| ## Nix git build example: | ||
| ```json | ||
| [ | ||
| { | ||
| "hostname": "artifactory-p101", | ||
| "store_path": "/nix/store/ldk0002skbab10v3b8xy343b33c2vffr-nixos-system-wharfix-p02-25.05pre-git", | ||
| "commit_hash": "dda93d97b7856c4ff7d3d959d0790ca6ad80d2bc", | ||
| "branch": "hostmap-ci-take-1", | ||
| "created_at": "2025-10-14 13:53:19+02:00" | ||
| }, | ||
| { | ||
| "hostname": "artifactory-p201", | ||
| "store_path": "/nix/store/ldk0002skbab10v3b8xy343b33c2vffr-nixos-system-wharfix-p02-25.05pre-git", | ||
| "commit_hash": "dda93d97b7856c4ff7d3d959d0790ca6ad80d2bd", | ||
| "branch": "hostmap-ci-take-2", | ||
| "created_at": "2025-10-14 13:53:19+02:00" | ||
| }, | ||
| { | ||
| "hostname": "artifactory-p301", | ||
| "store_path": "/nix/store/ldk0002skbab10v3b8xy343b33c2vffr-nixos-system-wharfix-p02-25.05pre-git", | ||
| "commit_hash": "dda93d97b7856c4ff7d3d959d0790ca6ad80d2be", | ||
| "branch": "hostmap-ci-take-3", | ||
| "created_at": "2025-10-15 13:53:19+02:00" | ||
| }, | ||
| { | ||
| "hostname": "ca-platform-p01", | ||
| "store_path": "/nix/store/ldk0002skbab10v3b8xy343b33c2vffr-nixos-system-wharfix-p02-25.05pre-git", | ||
| "commit_hash": "dda93d97b7856c4ff7d3d959d0790ca6ad80d2bf", | ||
| "branch": "hostmap-ci-take-4", | ||
| "created_at": "2025-10-16 13:53:19+02:00" | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| # Development | ||
| ## Initial setup | ||
|
|
||
| ```bash | ||
| nix develop | ||
| pg_initial_setup | ||
| cargo sqlx migrate run | ||
| cargo run -- test-assets/minimalTargetList.json | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get this output: |
||
| ``` | ||
|
|
||
| ## Development start | ||
| ```bash | ||
| nix develop | ||
| pg_setup | ||
| pg_ctl -D /PATH/TO/REPO/hostmap/.dev_postgres//data -l logfile start | ||
| DATABASE_URL="postgres://<USERNAME>:postgres@localhost:5432/hostmap-dev" cargo run -- test-assets/minimalTargetList.json | ||
| pg_start | ||
| ``` | ||
| **The following environment variables a set from flake.nix**\ | ||
|
|
||
| PG=$PWD/.dev_postgres\ | ||
| PGDATA=$PG/data\ | ||
| PGPORT=5432\ | ||
| PGHOST=localhost\ | ||
| PGUSER=$USER\ | ||
| PGPASSWORD=postgres\ | ||
| PGDATABASE=hostmap-dev\ | ||
| DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/$PGDATABASE | ||
|
|
||
| **run server:**\ | ||
|
|
||
| For the server to run in development we need a git repository and an API key. The API key is obtained from the GitLab UI.\ | ||
| If the API key is saved in the file `./api-key.txt` it will be ignored by git. | ||
|
|
||
| ``` | ||
| cargo run server --database-url $DATABASE_URL --repo-url https://somegit.myServer.dk/me/my-deployment --grouping-key host_group_name --api-key-file ./api-key.txt --columns "loc" | ||
| ``` | ||
|
|
||
| run activation logger: | ||
| ``` | ||
| ./target/debug/hostmap activation-logger --url-path /hostmap/hostmap-activation-logs.csv --activation-log-file /var/log/hostmap-activation-logs/hostmap-activation-logs.csv --server-ip 0.0.0.0 --port 9488 | ||
| ``` | ||
| run server: | ||
| cargo run server --database-url 'postgres://heze:postgres@localhost:5432/hostmap-dev' | ||
|
|
||
| run scraper: | ||
| cargo run scraper --host-group-file ./test-assets/minimalTargetList.json --scrape-interval 5 | ||
| ``` | ||
| cargo run scraper --hosts-file ./test-assets/minimalTargetList.json --scrape-interval 5 --activation-logger-port 9488 --api-key-file ./api-key.txt | ||
| ``` | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can bundle all the pgsql lines together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this?