{"id":19454859,"url":"https://github.com/jerakia/jerakia-ansible-lookup-plugin","last_synced_at":"2025-04-25T05:30:41.311Z","repository":{"id":83195276,"uuid":"99816037","full_name":"jerakia/jerakia-ansible-lookup-plugin","owner":"jerakia","description":"An Ansible lookup plugin for integrating with Jerakia","archived":false,"fork":false,"pushed_at":"2020-02-05T14:17:35.000Z","size":10,"stargazers_count":11,"open_issues_count":4,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T16:52:15.565Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jerakia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-09T14:12:55.000Z","updated_at":"2023-02-17T07:58:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"99c26a51-e249-46de-9258-75dd6622940c","html_url":"https://github.com/jerakia/jerakia-ansible-lookup-plugin","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerakia%2Fjerakia-ansible-lookup-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerakia%2Fjerakia-ansible-lookup-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerakia%2Fjerakia-ansible-lookup-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerakia%2Fjerakia-ansible-lookup-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jerakia","download_url":"https://codeload.github.com/jerakia/jerakia-ansible-lookup-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250760582,"owners_count":21482831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T17:12:16.020Z","updated_at":"2025-04-25T05:30:41.300Z","avatar_url":"https://github.com/jerakia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ansible-jerakia\n\n## Description\n\nThis is an ansible lookup plugin for integrating with Jerakia\n\n### Jerakia\n\n[Jerakia](http://jerakia.io) is a hierarchical lookup tool. It supports pluggable datasources and the ability to override values in the hierarchy using information about the requestor. See [The official Jerakia site](http://jerakia.io) for more general information on Jerakia.\n\n### Description\n\nThis plugin provides an interface between Ansible and Jerakia by way of a [lookup plugin](http://docs.ansible.com/ansible/latest/playbooks_lookups.html). Further plugin types are being investigated.\n\nA hierarchical lookup is made by applying a _scope_ against a hierarchy of lookup paths. A scope is simply information about the requestor, in this case the Ansible node, that it used in determining what data to return. A scope could consist of anything, typical things would be the hostname, environment and location of the node. Using the scope provided in the lookup, Jerakia will run through a hierarchy and return the relevant value.\n\nFor the examples in the next section, we assume that Jerakia Server is installed and running on it's default port on the local machine and that we have the following default policy configured in Jerakia\n\n```ruby\n# /etc/jerakia/policy.d/default.rb\n\npolicy :default do\n  lookup :default do\n    datasource :file, {\n      :format =\u003e :yaml,\n      :docroot =\u003e \"/var/lib/jerakia/data\",\n      :searchpath =\u003e [\n        \"node/#{scope[:hostname]}\",\n        \"environment/#{scope[:environment]}\",\n        \"operating_system/#{scope[:osfamily]}\",\n        \"common\"\n      ]\n    }\n  end\nend\n```\n\nSee [the official documentation](http://jerakia.io/basics/lookups/) for more information about Jerakia policies and lookups.\n\n### Configuration\n\nThe plugin will look for the `ANSIBLE_JERAKIA_CONFIG` environment variable to determine the location of the config file. If the variable is not set, it will look for a `jerakia.yaml` file in the directory where your playbook is located. The config file must contain an [authentication token](http://jerakia.io/server/tokens) to use to connect to Jerakia Server. We can also use the `scope` hash to map Ansible variables (facts) to the scope values used by the Jerakia policy above, eg:\n\n```yaml\ntoken: ansible:52cbf789c7837f9a4aef0d259c00d131f0f2a47894519c273c64a608de1382cba4221447752e9ac2\nscope:\n  hostname: ansible_nodename\n  environment: ansible_local.custom.environment\n  osfamily: ansible_os_family\n```\n\nNote that the scope keys in this example are the scope values used in the Jerakia policy, mapped to values which are Ansible variables (facts) for that request.\n\nSupported configuration parameters of `jerakia.yaml` are:\n\n| Parameter | Description | Required | Default |\n|-----------|-------------|:--------:|:-------:|\n| `token`   | The Jerakia token to use to authenticate against Jerakia server | Yes | - |\n| `scope`   | A hash containing the scope to use for the request, the values will be resolved as Ansible facts. Use a dot notation to dig deeper into nested hash facts (see `environment` above) | No | - |\n| `protocol` | The URL protocol to use | No | `http` |\n| `host`    | Hostname of the Jerakia Server | No | `localhost` |\n| `port`    | Jerakia port to connect to | No | `9843` |\n| `version` | Jerakia API version to use | No | `1` |\n| `policy`  | Jerakia policy to use for the lookups | No | `default` |\n\n### Usage\n\nOnce configured with a jerakia.yaml, you can call the Jerakia lookup plugin directly from your playbooks using the `lookup` method. The first argument is always the name of the plugin, `jerakia`, and the following arguments contain the namespace and key to lookup, which is formatted as `\u003cnamespace\u003e/\u003ckey\u003e`\n\n```yaml\n- hosts: all\n  tasks:\n    - debug: msg=\" {{ lookup('jerakia', 'apache/port') }}\"\n```\n\nIn the above example, if we assume the value of `ansible_nodename` is `foo.enviatics.com`, `environment` is `dev` and `ansible_os_family` is `RedHat` then with the policy we have declared, this will cause Jerakia to look up the key `port` in the namespace `apache`, it will follow the following hierarchy of files looking for the key `port` and return the first value it finds:\n\n* `/var/lib/jerakia/data/node/foo.enviatics.com/apache.yaml`\n* `/var/lib/jerakia/data/environment/dev/apache.yaml`\n* `/var/lib/jerakia/data/operating_system/RedHat/apache.yaml`\n* `/var/lib/jerakia/data/common/apache.yaml`\n\nSo we would be able to define a default value for the Apache port in `common/apache.yaml` but then have the ability to override this value based on a specific node, environment or operating system type. Note that the structure of the hierarchy here is purely an example, and is entirely configurable to suit your specific environment and needs.\n\n### Contributing\n\nThis is a very new project so contributions are always welcome, please submit a pull request in the first instance.\n\n### Maintainer\n\nThis project is maintained by Craig Dunn \u003ccraig@craigdunn.org\u003e - @crayfishx\n\n### License\n\nThis project is licensed under the Apache 2.0 license, please the the LICENSE file included with this software.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerakia%2Fjerakia-ansible-lookup-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerakia%2Fjerakia-ansible-lookup-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerakia%2Fjerakia-ansible-lookup-plugin/lists"}