tripleo-repos/tripleo-get-hash
Marios Andreou f584561253 Allow config overrides for TripleOHashInfo creation
Allows passing in a config dictionary into the TripleOHashInfo
constructor. This allows to override the loaded config for example
to pass in a dlrn_url. The passed config doesn't need to contain
all the config keys and the rest of the values are taken from the
loaded config file as before. This also adds a new parameter for
the ansible module so we can pass dlrn_url via ansible invocations.
Includes 2 new test cases for the new functionality. Used by [1].

[1] https://review.opendev.org/c/openstack/tripleo-quickstart/+/791486

Change-Id: I6e3e8663b7ca1ec2758843795142f91aa29fe74d
2021-07-08 15:54:07 +03:00
..
test Allow config overrides for TripleOHashInfo creation 2021-07-08 15:54:07 +03:00
tripleo_get_hash Allow config overrides for TripleOHashInfo creation 2021-07-08 15:54:07 +03:00
LICENSE Adds tripleo-get-hash module get tripleo-ci hash info from tag 2021-05-06 14:21:56 +03:00
README.md Adds tripleo_get_hash ansible module, example play & updates README 2021-05-17 13:10:03 +03:00
config.yaml add stein and queens to config 2021-05-17 11:38:16 -06:00
example_playbook.yaml Adds tripleo_get_hash ansible module, example play & updates README 2021-05-17 13:10:03 +03:00
requirements.txt Adds tripleo-get-hash module get tripleo-ci hash info from tag 2021-05-06 14:21:56 +03:00
setup.cfg Fixup setup.cfg paths for tripleo-get-hash 2021-05-28 13:00:57 +03:00
setup.py Adds tripleo-get-hash module get tripleo-ci hash info from tag 2021-05-06 14:21:56 +03:00
test-requirements.txt Adds tripleo-get-hash module get tripleo-ci hash info from tag 2021-05-06 14:21:56 +03:00
tripleo_get_hash.py Allow config overrides for TripleOHashInfo creation 2021-07-08 15:54:07 +03:00

README.md

tripleo-get-hash

What is tripleo-get-hash

This utility is meant for use by TripleO deployments, particularly in zuul continuous integration jobs. Given an RDO named tag, such as 'current-tripleo' or 'tripleo-ci-testing' it will return the hash information, including the commit, distro and full hashes where available.

It includes a simple command line interface. If you clone the source you can try it out of the box without installation invoking it as a module:

     python -m tripleo_get_hash # by default centos8, master, current-tripleo.
     python -m tripleo_get_hash --component tripleo --release victoria --os-version centos8
     python -m tripleo_get_hash --release master --os-version centos7
     python -m tripleo_get_hash --release train # by default centos8
     python -m tripleo_get_hash --os-version rhel8 --release osp16-2 --dlrn-url http://osp-trunk.hosted.upshift.rdu2.redhat.com
     python -m tripleo_get_hash --help

Quick start

Install using setup.py

Installation using python setup.py requires sudo, because the python source is installed at /usr/local/lib/python.

sudo python setup.py install

The tripleo-get-hash utility uses a yaml configuration file named 'config.yaml'. If you install this utility using setup.py as above, the configuration file is placed in /usr/local/etc:

     /usr/local/etc/tripleo_get_hash/config.yaml

Install using pip

You can also install using python pip - you can see the tripleo-get-hash module here

    pip install tripleo-get-hash --user

After installation you can invoke tripleo-get-hash --help to see the various options:

     tripleo-get-hash --help

By default this queries the delorean server at "https://trunk.rdoproject.org", with this URL specified in config.yaml. To use a different delorean server you can either update config.yaml or use the --dlrn-url parameter to the cli. If instead you are instantiating TripleOHashInfo objects in code, you can create the objects passing an existing 'config' dictionary. Note this has to contain all of constants.CONFIG_KEYS to avoid explosions.

Ansible Module

The tripleo-get-hash utility can be invoked from ansible using the tripleo_get_hash.py ansible module from the source tree. If you install tripleo-get-hash using python setup.py, the module will be installed for you at /usr/share/ansible/plugins/modules/ and is ready to use. Otherwise you will need to copy this file to somewhere that your ansible installation can find it. It is required that you install tripleo-get-hash either via pip or via setup.py before you can use the ansible module.

See the example playbook included here for examples of usage. You can also test the ansible module is available and working correctly from the bash shell:

$ ansible localhost -m tripleo_get_hash -a "component=compute release=victoria"
localhost | SUCCESS => {
    "changed": false,
    "commit_hash": "e954a56fec69637ebd671643d41bb0ecc85a2656",
    "distro_hash": "de7baf4889fba4d42ac39c9e912c42e38abb5193",
    "dlrn_url": "https://trunk.rdoproject.org/centos8-victoria/component/compute/current-tripleo/commit.yaml",
    "error": "",
    "extended_hash": "None",
    "full_hash": "e954a56fec69637ebd671643d41bb0ecc85a2656_de7baf48",
    "success": true
}