mlimaloureiro / ansible-maas-dynamic-inventory Goto Github PK
View Code? Open in Web Editor NEWDynamic inventory for MAAS
Dynamic inventory for MAAS
lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
When executing:
python3 maas.py --list
The following error is returned:
python3 maas.py --list
Traceback (most recent call last):
File "maas.py", line 11, in
import oauth2 as oauth
ModuleNotFoundError: No module named 'oauth2'
It seems there is no candidate for python-oauth2
sudo apt-cache search python-oauth2
python-oauth2client - OAuth 2.0 client library - Python 2.7
sudo apt-cache search python3-oauth2
python3-oauth2client - OAuth 2.0 client library - Python 3.x
There are candidates for:
sudo apt-cache search python-oauth
python-oauth - Python library implementing of the OAuth protocol
python-oauthlib - generic, spec-compliant implementation of OAuth for Python
python3-oauth - Python 3 library implementing of the OAuth protocol
python-oauth2client - OAuth 2.0 client library - Python 2.7
Installed both candidates but the result remains the same.
sudo apt-cache policy python-oauth
python-oauth:
Installed: 1.0.1-5
Candidate: 1.0.1-5
Version table:
*** 1.0.1-5 500
500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu bionic/main i386 Packages
100 /var/lib/dpkg/status
sudo apt-cache policy python3-oauth
python3-oauth:
Installed: 1.0.1-5
Candidate: 1.0.1-5
Version table:
*** 1.0.1-5 500
500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu bionic/main i386 Packages
100 /var/lib/dpkg/status
lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
There is no candidate for python3-requests_cache
sudo apt-cache policy python3-requests_cache
N: Unable to locate package python3-requests_cache
There is a candidate for python3-requests-cache
sudo apt-cache policy python3-requests-cache
python3-requests-cache:
Installed: 0.4.13-1
Candidate: 0.4.13-1
Version table:
*** 0.4.13-1 500
500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu bionic/universe i386 Packages
100 /var/lib/dpkg/status
when run using: python3 maas.py --list
The script returns correct dynamic inventory JSON from MAAS.
When run using: ansible all -i maas.py -m ping
The script returns:
ansible all -i maas.py -m ping
[WARNING]: * Failed to parse /home/netadmin/ansible-tst/maas.py with script plugin: Inventory script
(/home/netadmin/ansible-tst/maas.py) had an execution error: File "/home/netadmin/ansible-tst/maas.py",
line 32 def init(self, maas_api_url: str, maas_api_key: str): ^
SyntaxError: invalid syntax
[WARNING]: Unable to parse /home/netadmin/ansible-tst/maas.py as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does
not match 'all'
When run using: ansible apache-1 -i maas.py -m ping
[WARNING]: * Failed to parse /home/netadmin/ansible-tst/maas.py with script plugin: Inventory script
(/home/netadmin/ansible-tst/maas.py) had an execution error: File "/home/netadmin/ansible-tst/maas.py",
line 32 def init(self, maas_api_url: str, maas_api_key: str): ^
SyntaxError: invalid syntax
[WARNING]: Unable to parse /home/netadmin/ansible-tst/maas.py as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does
not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: apache-1
The code has 3 main classes:
Authentication
creates http headers to make signed requestsFetcher
is a class that fetches information from MAAS
API but also has some logic in fetch_machines_grouped_by_tags
method to group the machines by tagInventoryBuilder
uses data from Fetcher
and structure the data to match ansible inventoriesCurrently we're just testing the InventoryBuilder
class but since Fetcher
also has some logic and it's not only fetching we should test it.
Please create some tests to this class, specially, fetch_machines_grouped_by_tags
method
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.