Skip to main content

Generate config files from 'conf.d' like directories

Project description

update-conf-py-DO-NOT-USE

IMPORTANT: This is a fork of update-conf.py with the goal to test AWS CodePipeline as well as the whole AWS Code* stack. This project should NOT be used in production.

Also, the code will be stored into 2 repos: CodeCommit, to better test the full AWS Code* stack; GitHub, as Coveralls free plan only supports it.

Test Status Coverage Status PyPI - Python PyPI - Downloads PyPI - Version License

Default CodeBuild badge: Test Status

Badge via custom API based on eventbridge CodeBuild events: Test Status

Badge via custom API based on proxying the default CodeBuild badge: Test Status

Generate config files from conf.d like directories.

Split your config file into smaller files, called snippets, in a conf.d like directory. The generated config file will be the concatenation of all snippets, with snippets ordered by the lexical order of their names.

Files ending with .bak, .old and other similar terminations will be ignored.

This project was based on the update-conf.d project.

Install

This project works in Python 3 (3.7 or newer).

To install:

pip install update-conf-py-do-not-use

To install via AWS CodeArtifact:

CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token \
        --domain test --query authorizationToken --output text)
AWS_ACCOUNT=$(aws sts get-caller-identity --query "Account" --output text)
pip install update-conf-py-do-not-use \
        -i https://aws:${CODEARTIFACT_AUTH_TOKEN}@test-${AWS_ACCOUNT}.d.codeartifact.us-east-1.amazonaws.com/pypi/pypi/simple/

It's possible to clone the project in AWS CodeCommit and install it via setuptools:

git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/update-conf-py-DO-NOT-USE
cd update-conf-py-DO-NOT-USE
python setup.py install

Usage

To generate a config file, you can run something like this:

update-conf-py-do-not-use -f /etc/snmp/snmpd.conf

The example above will merge the snippets in the directory /etc/snmp/snmpd.conf.d into the file /etc/snmp/snmpd.conf.

If the directory containing the snippets uses a diferent name pattern, you can pass its name as an argument:

update-conf-py-do-not-use -f /etc/snmp/snmpd.conf -d /etc/snmp/snmpd.d

It's also possible to define frequently used options in a config file. For example, in /etc/update-conf-py-do-not-use.conf:

[snmpd]
file = /etc/snmp/snmpd.conf
dir = /etc/snmp/snmpd.d

Now, you can run:

update-conf-py-do-not-use -n snmpd

To get help:

update-conf-py-do-not-use --help

Config files

update-conf-py-do-not-use will use the global config file (/etc/update-conf-py-do-not-use.conf) or the user-home config file (~/.update-conf-py-do-not-use.conf) if they exist.

You can use the the sample config file (provided within the distributed package) as a start point:

cp ${prefix}/share/update-conf-py-do-not-use/update-conf-py-do-not-use.conf /etc/update-conf-py-do-not-use.conf

It's also possible to pass a custom config file via command line args:

update-conf-py-do-not-use -c my_custom_config.conf -n snmpd

More examples

Suppose you have 2 snippets. One is /etc/snmp/snmpd.conf.d/00-main:

syslocation Unknown
syscontact Root <root@localhost>

And the other is /etc/snmp/snmpd.conf.d/01-permissions:

rocommunity public 192.168.0.0/24

After running update-conf-py-do-not-use -f /etc/snmp/snmpd.conf, the generated config file will be:

# Auto-generated by update-conf-py-do-not-use
# Do NOT edit this file by hand. Your changes will be overwritten.

syslocation Unknown
syscontact Root <root@localhost>

rocommunity public 192.168.0.0/24

There are cases when it's useful to change the prefix used in the auto-generated comment. After running update-conf-py-do-not-use -f /etc/php.ini -p ';', the generated config will start with:

; Auto-generated by update-conf-py-do-not-use
; Do NOT edit this file by hand. Your changes will be overwritten.

It's also possible to set the prefix used in the auto-generated comment via config file. For instance, in /etc/update-conf-py-do-not-use.conf:

[php]
file = /etc/php.ini
dir = /etc/php.d
prefix_comment = ;

License

This software is released under the Revised BSD License.

Changelog

Check the CHANGELOG page.

Contributing

If you want to contribute with this project, check the CONTRIBUTING page.

TODO

  • Publish this software in a Ubuntu PPA.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

update-conf-py-do-not-use-1.1.0.dev7.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file update-conf-py-do-not-use-1.1.0.dev7.tar.gz.

File metadata

File hashes

Hashes for update-conf-py-do-not-use-1.1.0.dev7.tar.gz
Algorithm Hash digest
SHA256 917740d0ad4af9475cd4294302ffff84b84887a54567b1137e8ab16270d80dcc
MD5 89d426737e4e25e9cf07bdf93f233360
BLAKE2b-256 1956bb5cfe59ff799d26518e192ca0f938fa4e9dba4f364bac8ca7b83b572dc1

See more details on using hashes here.

File details

Details for the file update_conf_py_do_not_use-1.1.0.dev7-py3-none-any.whl.

File metadata

File hashes

Hashes for update_conf_py_do_not_use-1.1.0.dev7-py3-none-any.whl
Algorithm Hash digest
SHA256 feb1a2b5f73140a56c3d733ea0ce7e3c2e8006bfbeea452bfe1d03a1b5d2fe87
MD5 d67548522c885625bcbe469e4b012f48
BLAKE2b-256 69fb11a2101fd92ff1707dc876ba8a99c4ef939b4b72cda4cbcbc4ee72aedb83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page