#211 fix standard-inventory-rpm
Merged by astepano. Opened by bgoncalv.
bgoncalv/standard-test-roles fix-subject-standard-inventory-rpm  into  master

Download 211.patch

Solve dynamic inventory output:

ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS=local ansible-inventory --list

[WARNING]: * Failed to parse /usr/share/ansible/inventory/standard-inventory-rpm with script plugin: Invalid data from file, expected dictionary and got: None
[WARNING]: * Failed to parse /usr/share/ansible/inventory/standard-inventory-rpm with yaml plugin: Syntax Error while loading YAML. mapping values are not allowed in this context The error appears to have
been in '/usr/share/ansible/inventory/standard-inventory-rpm': line 37, column 15, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: def main(argv):
^ here
[WARNING]: * Failed to parse /usr/share/ansible/inventory/standard-inventory-rpm with ini plugin: /usr/share/ansible/inventory/standard-inventory-rpm:27: Expected key=value host variable assignment, got:
argparse
[WARNING]: Unable to parse /usr/share/ansible/inventory/standard-inventory-rpm as an inventory source

Maybe rewrite as:
else:
return EMPTY_INVETORY

?

rebased onto a28913d84cc51e82be32ec8431b52d1e2b9ebb87

thanks for the suggestion, I've updated it.

Hmm, how can I specify more rpms? This does not work:

[root@qeos-41 tests]# ansible-playbook -e subjects="file-5.31-11.fc27.x86_64.rpm file-5.31-12.fc27.x86_64.rpm" tests.yml

@bgoncalv I cannot reproduce the problem on master, do you have a reproducer @bgoncalv ?

rebased onto fd1ae938dae08786dbbcae3ff50204b86d766a79

@bgoncalv I cannot reproduce the problem on master, do you have a reproducer @bgoncalv ?

I reproduce it running: ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS=local ansible-inventory --list

with standard-test-roles-2.13-1.fc29.noarch and ansible-2.5.3-1.fc29.noarch.rpm.

rebased onto 35031bc4cc43fe0585e1389fd0c922d3197e9084

It is not clear what is TEST_SUBJECTS.

  1. package name for yum command
  2. package path for yum command

If we want to use package name than we use:

yum install zsh-5.0.2-28.el7

if we want to use package path then we use path in install command:

yum install /uri/or/path/to/file/zsh-5.0.2-28.el7.x86_64.rpm

It seems that this inventory script supports ONLY path/uri to .rpm file.

This PR makes a lot of copies hosts "rpms":

# TEST_SUBJECTS="zsh-5.0.2-28.el7.x86_64.rpm bash-5.0.2-28.el7.x86_64.rpm" ./standard-inventory-rpm --list
...
{
    "subjects": {
        "hosts": [
            "rpms",
            "rpms"
        ],
        "vars": {}
    },
    "_meta": {
        "hostvars": {
            "rpms": {
                "ansible_connection": "local"
            }
        }
    },
    "localhost": {
        "hosts": [
            "rpms",
            "rpms"
        ],
        "vars": {}
    }
}#                                 

rebased onto 26ab4c034b54c82f2f711d4aa37c43d61a581479

Thanks I've updated the PR to fix the multiple copies of "rpms".

Note the script never accepted 'package name for yum command'. It excepted hte file to end with .rpm.
Sure, if you want the script can be updated to support it.

@bgoncalv nice, I like this approach.
ACK to merge it.
If we want to support 'package name for yum command' than it should be done in different PR.
Thank you.

Commit f9203513 fixes this pull-request

Pull-Request has been merged by astepano

Pull-Request has been merged by astepano

Metadata