How to provide npm dependencies in AWX - ansible

I have a playbook that makes use of a lookup plugin to fetch data from netbox (netbox.netbox.nb_lookup).
I have created a requirements.yml file, so that the collection netbox.netbox is automatically installed by AWX.
However, I get the following error when I try to launch my playbook in AWX:
An unhandled exception occurred while running the lookup plugin 'netbox.netbox.nb_lookup'. Error was a <class 'ansible.errors.AnsibleError'>, original message: pynetbox must be installed to use this plugin. pynetbox must be installed to use this plugin
The error message is pretty clear about the issue: The dependency pynetbox is missing.
This could be resolved by running
pip install pynetbox
and in fact, I did this in my local environment and the playbook works fine, including the query with netbox.netbox.nb_lookup.
What is the best option to provide the AWX container with the required dependency from the npm repository?

Related

openliberty 22.0.0.7 - unable to install features

I have installed openliberty 22007, and am trying to install the samlWeb-2.0 feature. This fails with
./featureUtility installFeature samlWeb-2.0 -v
Initializing ...
Using 8 threads to download artifacts.
CWWKF1409E: Unable to find the following feature JSON files locally or on the configured Maven repository: [io.openliberty.features:features:22.0.0.7].
If I try to run ./featureUtility find - it also fails with the same message. Other openliberty runtimes I have installed work.

How to keep collection alongside playbook and push to own github repo?

My current playbook is structured this way
projectroot
|
|--ubuntu2004
|
|--00_setup
|
|--vars
|--playbook.yml
|--readme.md
Because my playbook uses ansible.posix and I also commit my playbook into a github repo. I was hoping if there's a way to include the required collection in this case ansible.posix as a requirement and how do I install it?
I saw that there are multiple ways https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#installing-collections
I was wondering what's the best practice way that makes sense when using a github repository as version control for the playbook?
There's a few ways that you could do this. I'd suggest a requirements file since it's the easiest to set up and to manage.
Create a requirements file that you use to install the required modules.
The best way would be to create a requirements file that references the collection(s) your playbook needs. Which you can then use to install the required collection(s) and / or role(s).
---
collections:
- name: ansible.posix
Store the module in a repository and install it through ansible-galaxy.
You could upload the module to a git repository and then install it. I wouldn't recommend this as storing dependencies in your source-code isn't considered a good practise when there's a tool to manage dependencies available.
ansible-galaxy collection install
git+https://github.com/organization/repo_name.git,devel
Install the module through a playbook
I've set up a master node to run playbooks on with Ansible before and installed modules through the command task in a playbook. As long as you don't reference / include any tasks or plays that use the module, this will work fine.
- name: Install ansible posix module
command: ansible-galaxy collection install ansible.posix
The ideal way would be to have to playbook install the required module(s) prior to executing the tasks. However it's not possible to ignore the error that is thrown when a module is missing, so you would have to have to create a play that doesn't include / reference any of the tasks using the module.

Error due to "BuildRequires: maven-local" in spec file for Packaging Maven project

Issue : I am following the URL. https://docs.fedoraproject.org/en-US/java-packaging-howto/packaging_maven_project/ to create a spec file for the rpm package.
In the website "BuildRequires: maven-local" is mentioned in the spec file.
but when I tried to search 'maven-local' using yum search maven-local command, I could not find anything and as I was not able to install the component, I'm getting an error when I am trying to do rpmbuild.
Note: I even installed maven separately in my system but it did not help me to fix the issue.

Webpack compilation, local Module not found: Error: Can't resolve

I modified a plugin and added it in my project's file system. So in my package.json I have : "some-module": "file:modules/some-module".
It works fine on my machine (Windows), but not on our build server (Linux CentOS), which fails during webpack compilation with error : Module not found: Error: Can't resolve 'some-module'.
The build server does clean the workspace before build, and after the failed build the plugin does exist in 'node_modules' folder of the workspace.
What could cause this error if the plugin does exists ?
EDIT : I tried on another linux machine (CentOS) and build failed for same error.
EDIT2 : I changed the local file: reference in my package.json file to a .tar.gz git URL. The error is now :
ERROR in ../node_modules/nativescript-pdfview-ng/pdfview-ng.ts
Module build failed (from ../node_modules/#ngtools/webpack/src/index.js):
Error: /root/myProject/node_modules/nativescript-pdfview-ng/pdfview-ng.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format ([link][1]).
at AngularCompilerPlugin.getCompiledFile (/root/myProject/node_modules/#ngtools/webpack/src/angular_compiler_plugin.js:719:23)
at plugin.done.then (/root/myProject/node_modules/#ngtools/webpack/src/loader.js:41:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
Are you using NativeScript 5.x?
If so, make sure to prefix the plugin with "nativescript-", since {N} 5.x the module resolution seems to have changed with regards to Webpack'ed build.

using ansible modules from git repository?

I have a playbook and a bunch of modules I wrote.
Now I want to reuse the same modules in my next playbook for a different project.
I really want to push those modules to a public git repository and then somehow tell ansible to use the modules from the git repository.
(kinda like npm package.json referencing github)
I can't seem to find any documentation on how to do that.
For now, I am using a workaround where I tell people to npm install the repository, and then define ANSIBLE_LIBRARY variable.
How can I tell the playbook to load modules from a github repository or some other remote location?
Actually modules can be nested inside roles since quite a long time. Since Ansible 2 this even is possible with most of the plugins.
The folders where the modules & plugins need to be stored inside the role is the same as on playbook level. Modules go into library, plugins go into *_plugins (action_plugins, callback_plugins, filter_plugins etc)
To make the module/plugin then available the role has to be applied to the playbook (or added as a dependency of another role)
Only exception known to me are variable plugins and that perfectly makes sense. Since variable plugins are executed when the inventory is read, which happens before roles are interpreted.
vars_plugins still can be distributed in roles, but the path needs to be added in the ansible.cfg. Fortunately you can also use wildcards in paths:
vars_plugins = roles/*/vars_plugins
And no, all of this is not documented in any way. :)
Finally, to distribute roles you can use Ansible Galaxy:
ansible-galaxy install foo
Nothing wrong with directly using git. Ansible Galaxy actually only is a tool to install git repositories. But since Galaxy is the Ansible standard I suggest to at least provide a Galaxy compatible format. A good (best?) practice how to install Galaxy roles separate from the projects roles can be found here.
Here's an example for an action plugin: https://galaxy.ansible.com/udondan/ssh-reconnect/
There is no solution for that at the moment. Maybe you can add a playbook to download the modules to your project to avoid npm, but thats even not that nice.
I have my custom modules in a directory next to my playbooks. This directory is defined in my global ansible.cfg file:
library = /usr/share/ansible
The only drawbag here is that i allways have the same version for modules on all playbboks.

Resources