I'm running Ansible version 2.9.14 and I've already downloaded the "cisco.ios" Ansible collection. However, when I look in my directory, "ansible_collections/cisco/ios/plugins/modules" I don't seem to have a .py file for ios_ospf_interfaces. Consequently when I include a task in a playbook that references this module the task produces an error.
I tried to install the cisco.ios collection again, but my system reported it already had this collection and didn't do anything further. So how can I get this particular module on my system?
Thanks!
Existing Ansible Modules On My System
(credit for this answer goes to mdaniel)
When using the standard command, "ansible-galaxy collection install cisco.ios" it's possible that you may not receive the latest version of this collection.
In this instance, the version of the collection that was installed on my system was 1.1.0 and yet to obtain the "ios_ospf_interfaces" module I needed 1.2.0
To verify the current version of the cisco.ios module the command is:
ansible-galaxy collection install -vv cisco.ios:==1.2.0
If the output displays that you are running an earlier version of this collection, repeat the command above but add the argument, "--force" at the end to force it to update to version 1.2.0
Related
I'm writing some ansible code to update a project from gitlab so I need to first check if the host computer and the version I'm trying to install are different from one another. I find the version on Gitlab from the file at
https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/master/download?job=test
using the uri module in ansible. The file downloaded has the version number in its name. "CompanyName-VersionNumber.zip"
But this has the effect of downloading the file as well. I want to be able to check what file would be downloaded before actually downloading it so I can do a version check.
This code will be run on both windows and linux machines, so if possible something that works on both would be preferred.
Is that means ansible modules are in same version with ansible
Ansible modules - these modules ship with ansible
If not then how to check which version of ansible modules I have?
Q: Are ansible modules the same version with ansible?
A: Looking at the ansible repository -> tag stable-v2.0.
https://github.com/ansible/ansible/tree/stable-2.0/lib/ansible/modules
Since ansible/modules/core is a submodule-reference to the ansible-modules repository found here. This means that when an ansible developer do a git clone --recursive to checkout the entire set of code, git will checkout codes from ansible and ansible-modules repositories to make up the "entire set of code".
So when a developer goes on to build the binary from the full ansible source code, I would assume that only one distinct version number is given to it.
Therefore, short answer is; yes. They share the same version number.
There's 99% probability that you have it the same version as Ansible "kernel", unless you installed Ansible from sources and updated modules subtrees manually.
ansible-modules-core and ansible-modules-extras were split from main ansible repo for some time, but later merged again. You can read about it here.
But Ansible packages has been always released as self-contained, so if your modules' versions are the same as Ansible version in ansible --version command.
Jython Package installation issue, using pip
Hi, I have installed Jython2.7 configured with pydev in eclipse neon, also configured python 3.6 package
I am able to install packages for python using pip installer?
pip install "packagename"
Below are some of the packages in python/Lib/Site-packages directory
I was able to install all the packages
How do I use pip installer to install packages for jython?
I tried to install Jip package with
jython install setup.py
The binary File got installed in the Jython/Lib/Site-packages folder
However, I am not able to use it.
where and how do I get Jython package binaries like jip?
Also, Please let me know how to search jython packages?
Also, How to make pip install library packages in jython?
Any other configuration like jython home, etc that should be made?
This answer is going to be really generic but I just recently have slogged my way through the setup for jython/jip/pip and here's roughly what I had to do.
Firstly, I'm running Windows 7 64 Bit from behind a proxy (work machine.)
Had to install jython 2.7.0 instead of 2.7.1 because (I think anyway) 2.7.1 requires admin privileges which I don't have on my work PC.
Pip didn't install correctly during the Jython installation and I spent an obscene amount of time trying to get it installed and functioning as I knew it from my cpython days. NOTE: Just because you get pip installed, doesn't mean you can use any package on a python package repo. As of 2.7.0, Jython doesn't have end to end capability to interpret/compile some libraries that rely on certain python wrappers of native OS function calls. I believe 2.7.1 makes solid progress in the direction of supporting all needed native calls but don't quote me on that. For example, I tried to use wxPython to make a simple GUI to test my jython install. Trying to install it from pip kept causing really non-specific error info that took me a lot of time to figure out that the cause was jython simply couldn't compile the wxPython source so beware.
I had to set environment variables 'http_proxy' and 'https_proxy' in the form of http://proxyhosturl:port and https://proxyhosturl:port respectively to get out from behind the proxies without having to invoke pip with the proxy switch every time I called it.
To actually install pip, have a look here. These instructions are for Python and Linux/Unix but the principle is roughly the same. Just use jython -m instead of python -m and ignore the '$' at the start of each command line.
Also be sure to CD to your python_home/bin folder when invoking the ez_install exe.
If that doesn't work (didn't for me), try using get-pip.py script with these instructions https://pip.pypa.io/en/stable/installing/ (remember jython instead of python etc.). Download it, cd to the download location and follow the noted install steps. Worth noting is about half way down the install instructions where it details installing from local archives (source/binary zip or tar.gz archives of pip and setuptools as better described here: https://packaging.python.org/tutorials/installing-packages/#installing-from-local-archives).
The links to the bin archives of pip and setuptools are here:
https://pypi.python.org/pypi/setuptools
https://pypi.python.org/pypi/pip
It may also be worth making sure that your PATH environment variable has the jython/bin path in the variable value. The jython installer should do this but, again, mine did not.
If all goes well, you should be able to invoke pip with the --version switch and if it prints a line with the installed pip version info then you should be good to go
Another quirky issue I had was I could invoke a function of pip one time and any subsequent times I would get a stack trace ending with something along the lines of an object not having a certain property. I fixed that by finding my temp directory by opening a windows explorer instance and typing %TEMP% in the address bar and hitting enter, it should take you to a subdir of your AppData folder and there you may see a folder with the name of the package you were trying to install and the text "_pip" somewhere in the directory name. Delete the directory and try the pip install command again. I had to do this + invoke pip install pip -U to update my install to the latest version. Then pip began behaving correctly in my instance.
pip search numpy (or your library name) will generate a list of results with the same logic it uses to locate your desired package when you call pip install but, again, just because it returns a matching package doesn't mean it will compile when you install it (numpy doesn't work because of the missing java to C native function calls I described earlier.) The trade off is that you can import code artifacts from Java JAR files in your Jython script files and leverage their functionality with relative ease. Between the public Java APIs available and the python packages that work with the jython interpretor, you can (in my experience) come up with a way to accomplish your task. See the following info on JIP, Maven and IDEs.
IDE and jython integration (Eclipse)
- If you are stuck using Eclipse (like me) it actually has pretty decent support for python development. Install the PyDev plugin for Eclipse from Help -> Install Software. Put in this URL https://marketplace.eclipse.org/content/pydev-python-ide-eclipse, hit tab, and select the PyDev plugin and hit 'finish.'
- Setup the jython interpretor info from Windows -> Preferences -> PyDev. Provide the path to your jython.jar file.
- You should now be able to use File -> New PyDev project to create a basic python project and configure it to use your version of Jython and Java.
Brief Overview of Jip and Maven
- jip is a jython package that is invoked very similarly to pip but instead will download JAR files from the Maven Central Repository instead of python packages from pypi.com, for example. See the install instructions described here. Note the install procedure for a global jip install which differ from just pip install jip. https://pypi.python.org/pypi/jip/
- I never got jip to work exactly as I wished because there's not a ton of documentation on it outside of what I already linked. However, if you install a JAR using jip, you have to go to your project in Eclipse and actually add the JARs themselves to your PYTHONPATH in order for import statements and editing to have intellisense and so that you don't get a classnotfound exception at runtime. See following screen shot.
- There is a JIP config file that you can use similar to the pip config ini file but I have yet to find any exhaustive documentation on it's setup.
Note in the above screen shot the first entry in the External libraries entries. By default, pip places installed packages in that directory so to enable eclipse to find them, you need to also ensure that location is entered.
In Conclusion
- I have more to add to this answer and I will do so as soon as possible. In the meantime, see this example project I've loaded into github.
https://github.com/jheidlage1222/jython_java_integration_example
It shows basic config and how to interface with JARs from python code. I used the apache httpcomponents library as an example. Good luck amigo.
I have found this DNSimple ansible module:
http://docs.ansible.com/ansible/dnsimple_module.html
but can not find anywhere on that page to download and install it? How do I go about downloading and installing ansible modules like this. Thanks.
The accepted answer solved the questioner's problem but didn't address the broader scope of the question.
How to install an Ansible module? The documentation is currently vague as to how to achieve this simple requirement!
An excellent general guide to writing modules (I've no connection to the author) can be found here.
The quickest way is to simply have a folder called library/ in the same folder as your playbook. Inside this folder, place the python script for the Ansible Module. You should now have a corresponding task available to your playbook.
If you want to share your module across multiple projects, then you can add an entry to /etc/ansible/ansible.cfg pointing to a shared library location, eg:
library = /usr/share/ansible/library
The module itself is part of ansible since version 1.6 (as stated here). To use it, you need to have dnsimple on your host machine (also stated in the above description). Install it with sudo pip install dnsimple
It is important to know that base ansible modules are not installed by default on devel version, which is the default installed version when you build from source.
Only few modules are present for developpment purpose.
So when you'll run your playbook it'll complain about not found module with following error message
couldn't resolve module/action 'xxx'
If you have no choice but building for source, don't forget to checkout the stable branch to install all basic ansible modules!
When I try to use the Ansible's Composer module and paste the following task into my playbook.yml file I get an error.
playbook.yml
- name: Composer Install Site Dependencies
composer: command=install working_dir=/var/www/html
Error:
ERROR: composer is not a legal parameter in an Ansible task or handler
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
After some investigation I ran "anisble-doc --list" on the command line to see the available modules and "composer" is not listed. I am running Ansible version 1.5.4, do I have to add it separately?
As #user272735 indicated in the comments, this is an unreleased module- it's slated for the 1.6 release, which is under "active development". (admittedly it was originally slated for 1.4) You have a couple of options:
install ansible from the bleeding edge. See "running from source". (obviously, this is scary)
ninja-patch the file into your locally installed tree. (obviously, this is scary)
add the file into your local Ansible repo.
As "developing modules" says, a fourth option is to specify your library path via ANSIBLE_LIBRARY or --module-path. HOWEVER, this overrides your global library/module path. That isn't what you want to do unless you are providing every module.
adding into your repo
I'm assuming your repo is named "ansible" and is set up properly, like this:
ansible/
ansible/roles/
ansible/group_vars/
In that case, simply add a library directory at the top (the 'best practices' discusses this but not in the expected section):
ansible/
ansible/roles/
ansible/group_vars/
ansible/library/
Inside there, add the composer file in there. That makes its path/file the following:
ansible/library/composer
Note it is not composer.py or anything else. Also, it doesn't seem to need the +x bit, so no fussy worries there.
Once you do that, you can run Ansible commands as you'd expect. The composer module will simply be there.