New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongo Inventory #22234

Open
wants to merge 5 commits into
base: devel
from

Conversation

Projects
None yet
6 participants
@prakritish

prakritish commented Mar 3, 2017

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

mongo.py
mongo.ini

ANSIBLE VERSION
[root@prakritish1 ~]# ansible --version
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
[root@prakritish1 ~]#
SUMMARY

This is an inventory module which allows users to user Mongo DB to
store inventory information. As ansible allows various hostvars, I thought
it's much more simpler to use Mongo to store relevant information in a
collection rather than using SQL with empty columns.

[root@prakritish1 inventory]# ./mongo.py --list
{"web": ["prakritish3.mylabserver.com"], "_meta": {"hostvars": {"prakritish3.mylabserver.com": {"ansible_become_user": "root", "ansible_become": true, "ansible_ssh_pass": "abcde12345", "ansible_user": "user", "ansible_become_pass": "abcde12345"}}}}
[root@prakritish1 inventory]# ./mongo.py --host prakritish3.mylabserver.com
{"ansible_become_user": "root", "ansible_become": true, "ansible_ssh_pass": "abcde12345", "ansible_user": "user", "ansible_become_pass": "abcde12345"}
[root@prakritish1 inventory]# ansible -i ./mongo.py prakritish3.mylabserver.com -m command -a "/sbin/ifconfig"
prakritish3.mylabserver.com | SUCCESS | rc=0 >>
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.31.229  netmask 255.255.240.0  broadcast 172.31.31.255
        inet6 fe80::4f3:58ff:fe4a:4d67  prefixlen 64  scopeid 0x20<link>
        ether 06:f3:58:4a:4d:67  txqueuelen 1000  (Ethernet)
        RX packets 1173  bytes 337505 (329.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1225  bytes 150710 (147.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 18  bytes 1136 (1.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18  bytes 1136 (1.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@prakritish1 inventory]#
@mattclay

This comment has been minimized.

Member

mattclay commented Mar 3, 2017

Please rebase your PR to re-run CI.

@mattclay mattclay added the ci_verified label Mar 3, 2017

prakritish added some commits Mar 3, 2017

File: mongo.py
Description: This script allows ansible inventory to be managed in
MongoDB.

File: mongo.ini
Description: Configuration file for mongo.py

@prakritish prakritish force-pushed the prakritish:mongo branch to 7b20ab4 Mar 4, 2017

@ansibot ansibot removed the ci_verified label Mar 4, 2017

prakritish added some commits Mar 4, 2017

Updating mongo.py to:
* make dict iteration compatible for python3
* removing trailing white spaces

@ansibot ansibot removed the needs_revision label Mar 4, 2017

@prakritish

This comment has been minimized.

prakritish commented Mar 7, 2017

The PR is rebased as requested!

@gundalow

This comment has been minimized.

Contributor

gundalow commented Nov 29, 2018

Close/open to trigger CI

@ansibot ansibot removed the stale_ci label Nov 29, 2018

@ansibot

This comment has been minimized.

Contributor

ansibot commented Nov 29, 2018

The test ansible-test sanity --test pylint [explain] failed with 4 errors:

contrib/inventory/mongo.py:87:0: anomalous-backslash-in-string Anomalous backslash in string: '\['. String constant might be missing an r prefix.
contrib/inventory/mongo.py:87:0: anomalous-backslash-in-string Anomalous backslash in string: '\]'. String constant might be missing an r prefix.
contrib/inventory/mongo.py:87:0: anomalous-backslash-in-string Anomalous backslash in string: '\d'. String constant might be missing an r prefix.
contrib/inventory/mongo.py:87:0: anomalous-backslash-in-string Anomalous backslash in string: '\d'. String constant might be missing an r prefix.

The test ansible-test sanity --test pep8 [explain] failed with 7 errors:

contrib/inventory/mongo.py:59:1: E302 expected 2 blank lines, found 1
contrib/inventory/mongo.py:86:49: E203 whitespace before ':'
contrib/inventory/mongo.py:87:23: W605 invalid escape sequence '\['
contrib/inventory/mongo.py:87:26: W605 invalid escape sequence '\d'
contrib/inventory/mongo.py:87:32: W605 invalid escape sequence '\d'
contrib/inventory/mongo.py:87:36: W605 invalid escape sequence '\]'
contrib/inventory/mongo.py:137:1: E305 expected 2 blank lines after class or function definition, found 1

click here for bot help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment