etckeeper | special support to handle changes | Command Line Interface library
kandi X-RAY | etckeeper Summary
kandi X-RAY | etckeeper Summary
etckeeper has special support to handle changes to /etc caused by installing and upgrading packages. Before apt installs packages, etckeeper pre-install will check that /etc contains no uncommitted changes. After apt installs packages, etckeeper post-install will add any new interesting files to the repository, and commit the changes. You can also run etckeeper commit by hand to commit changes. There is also a cron job, that will use etckeeper to automatically commit any changes to /etc each day.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Run the pre - commit hook .
- Pre - install pre - install .
- Post - install .
etckeeper Key Features
etckeeper Examples and Code Snippets
Community Discussions
Trending Discussions on etckeeper
QUESTION
My use-case is versioning application changes on server because sometimes I need to rollback previous version before update, or before configuration changes.
This is my list of content:
...ANSWER
Answered 2019-Sep-26 at 08:25Solution was easy & clean, i hope :)
QUESTION
I use etckeeper
for revision control of my /etc
directory.
Due to the owership of the files under /etc
, I need to run git
as root.
How can I do this and still easily have access to all my beloved git
aliases and other config?
ANSWER
Answered 2019-Jun-11 at 09:11git -c include.path=
will include the configuration in .
To automatically pull in my non-root user's config files, I use the bash
alias:
QUESTION
When I run the ansible dnf module, the messages dnf writes through the logging
module do not appear to go anywhere. Why does this happen?
I have a call chain something like:
ansible (python3) -> ansible dnf module -> import dnf
... -> dnf plugin etckeeper-dnf
The current version of etckeeper-dnf goes on to run etckeeper
, using os.system()
. So it writes to stdout and confuses ansible. I assume this is an error in etckeeper-dnf. I am fairly confident that ansible is allowed to import dnf
etc. I came across another fix for a dnf plugin that says the dnf cli
objects are not necessarily available, which sounds like a similar scenario.
It seems reasonable for Ansible to want to be able to control stdout/stderr, and not have them interfered with by library code.
So I have patched etckeeper-dnf and I am effectively piping it's stdout+stderr to the python logging
module. This does exactly what I wanted. It fixes Ansible. And the dnf
command still shows all the etckeeper messages. (They are also now copied to /var/log/dnf.log
).
But now I have a reading comprehension problem.
When I run the ansible dnf module, the messages dnf writes through the logging
module, including from etckeeper-dnf, do not appear to go anywhere.
That's not my change, not my fault, and it's not something I need. I even tested what would happen if etckeeper fails: etckeeper-dnf just continues, so Ansible wouldn't show any warnings about it anyway (unless I deliberately broke Ansible).
But I can't help but feel uncomfortable about the idea that any warning messages are going to be lost.
I made sure to test using dnfpluginscore.logger.error()
, as well as .info()
, but I don't see the messages in either case.
The default configuration of the logging
module is to write to stderr. The dnf
module does not do anything to configure it, unless you use dnf.cli.BaseCli
. The Ansible module dnf.py
does not use anything from dnf.cli
, and does not do anything with logging
. The base class AnsibleModule
does not use python logging
either; it has its own independent .log()
method.
So why do the messages written with .error()
not appear on the Ansible module output pipe, and break Ansible again?
- ansible-2.7.10-1.fc29.noarch
- dnf-4.2.2-2.fc29.noarch
- python3-3.7.3-1.fc29.x86_64
ANSWER
Answered 2019-Jun-07 at 10:43The original etckeeper-dnf
broke Ansible because it wrote to stdout. Whereas we determined that the python logging
module writes to stderr.
If you look at the output in the link, Ansible separates module_stdout
and module_stderr
. Usually it just ignores module_stderr
; it only shows it in case of MODULE FAILURE
. (Although some other modules do not always separate stdout/stderr, e.g. the Ansible script
module).
So I still think the proposed change in etckeeper-dnf is reasonable. And regardless of how deliberately the Ansible dnf module was designed this way, it seems fairly reasonable to rely on this specific behaviour. The changed code is unlikely to be broken by future changes in the Ansible dnf module.
I would note that when you hit a MODULE FAILURE
, module_stderr
only shows dnf's error messages. You do not see any messages from loglevel INFO or below, i.e. dnf's usual non-error, non-interactive output.
(If etckeeper failures were treated as fatal when using etckeeper-dnf, then it might not be a great idea to log all the etckeeper output using .info()
. Ansible would miss the original error messages from etckeeper (and the error messages would not be logged anywhere else).
However, I tested the system after hacking etckeeper to return EXIT_FAILURE
. IIRC, dnf continued regardless of any etckeeper failure. The overall effect is that Ansible will not give you any information about the failure to run etckeeper, regardless of how I log errors. And in general, treating stdout
and stderr
messages separately is more complex and does weird things to the order of messages. So I followed the K.I.S.S. principle :-).
Or to put it more generally:
As per default, logging
messages written at loglevel INFO and below will go nowhere. Messages at loglevel WARNING and above will go to stderr. They will not interfere with normal Ansible module operation. In normal Ansible module operation, even these messages will not go anywhere.
If there is a MODULE FAILURE
- i.e. the module crashes or does not generate JSON output that Ansible can parse as expected - Ansible will show module_stderr
, which includes logging
messages at or above loglevel WARNING only.
QUESTION
I'm trying to add a daily cron job to backup a database. I'm able to do it manually by running sh /path/to/file/backup.sh
but when I place the file in the cron.daily directory, it doesn't run daily. To try and diagnose it, I created a test file in cron.daily called test just to see if it would run. When I ran run-parts --test /etc/cron.daily
, I got the output
/etc/cron.daily/apache2
/etc/cron.daily/apt
/etc/cron.daily/bsdmainutils
/etc/cron.daily/dpkg
/etc/cron.daily/etckeeper
/etc/cron.daily/logrotate
, etc.
So then I tried copying the content of logrotate to a new file, atest, then ran run-parts again but with the same results.
atest:
...ANSWER
Answered 2017-Apr-26 at 22:01There are a couple of things that can keep files within your /etc/cron* directories from running (e.g. /etc/cron.daily):
Permissions. Make sure the permissions of the files are 0644.
The filename must meet certain conditions. From the documentation: "...they must be entirely made up of letters, digits and can only contain the special signs, underscores ('_') and hyphens ('-'). Any file that does not conform to these requirements will not be executed by run-parts.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install etckeeper
You can use etckeeper like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page