comtrya / comtrya

Configuration Management for Localhost / dotfiles
https://comtrya.dev
MIT License
483 stars 44 forks source link

Feature: history / status #400

Open shawn111 opened 6 months ago

shawn111 commented 6 months ago

Description

Comtrya is awesome, it is so flexible compare to other dotfile managers. Could we have some methods to measure what manifests status in machine?

related issue: #254

Additional information

Something like dnf history:

# dnf history
ID     | Command line                                                                               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------------------------------------------------------------------------
    16 | install perl                                                                               | 2024-02-25 21:29 | Install        |  196
    15 | install openssl1.1-devel --allowerasing                                                    | 2024-02-25 21:28 | E, I           |    3
    14 | install -y openssl openssl-libs openssl-devel pkg-config                                   | 2024-02-25 21:26 | Install        |    2
    13 | install -y gcc                                                                             | 2024-02-24 21:28 | Install        |    8
    12 | remove wezterm                                                                             | 2024-02-23 17:20 | Removed        |    2
$ comtrya histroy
ID     | Command line                                                                               | Date and time    | Action(s)       | 
-------------------------------------------------------------------------------------------------------------------------------------------------
    16 | apply abc                                                                               | 2024-02-25 21:29 | File, Command    |  
    15 | apply foo                                                                               | 2024-02-25 21:28 | File, Package        |   
$ comtrya status

manifests                                                  |                   applied time
-------------------------------------------------------------------------------------------------
foo                                                              |              2024-02-25 21:29 
icepuma commented 6 months ago

I think we could easily write something like a history or add an adapter framework to write the history to "SQLite", "file", ...

Takes a bit of brainstorming, but could be a cool feature. We have to be aware of redacting secrets and other sensitive information.

shawn111 commented 6 months ago

@icepuma https://github.com/comtrya/comtrya/pull/407

I added tracing_journald support. It allows linux users (systemd) to review specific manifest or action logs.

╰─❯ journalctl -t comtrya F_MANIFEST=github -p 5

Mar 07 13:18:27 fedora comtrya[413440]: nothing to be done to reconcile action
Mar 07 13:18:27 fedora comtrya[413440]: Completed
Mar 07 13:20:55 fedora comtrya[414248]: need to define action summarize
Mar 07 13:20:55 fedora comtrya[414248]: not found action summarize
Mar 07 13:20:55 fedora comtrya[414248]: Completed
Mar 07 17:31:40 fedora comtrya[481344]: nothing to be done to reconcile action
Mar 07 17:31:40 fedora comtrya[481344]: Completed

╰─❯ journalctl -t comtrya F_MANIFEST=github -p 4

Mar 07 13:20:55 fedora comtrya[414248]: need to define action summarize

For manifest status and long term, I like the db or files framework idea that works for all platforms.