Hello folks!

I'm creating an Action plugin to query a file for contents.

I aim to publish it at Ansible Galaxy for myself to use, and perhaps it 
will be useful for someone else as well. It's my first Ansible plugin, and 
it's been a couple of years since I last touched Python as well, so I am in 
need of some guidance.

I have this file tree:

ansible_collections/
└── myns
    └── query_file
        ├── galaxy.yml
        ├── LICENSE
        ├── meta
        │   └── runtime.yml
        ├── plugins
        │   ├── action
        │   │   ├── args.json
        │   │   ├── query
        │   │   │   ├── config.py
        │   │   │   ├── parse.py
        │   │   │   ├── parse_target_container.py
        │   │   │   ├── select_columns.py
        │   │   │   ├── target_from.py
        │   │   │   ├── target.py
        │   │   │   ├── test_parse_dict.py
        │   │   │   ├── test_parse_list.py
        │   │   │   ├── test_parse.py
        │   │   │   ├── test_parse_target_container.py
        │   │   │   ├── test_select_columns.py
        │   │   │   ├── test_shared.py
        │   │   │   ├── test_target_from_string.py
        │   │   │   ├── test_target_init.py
        │   │   │   └── test_target_match_in.py
        │   │   └── query_file.py
        │   └── README.md
        ├── README.md
        ├── requirements.txt
        └── tests
            ├── integration
            │   ├── inventory
            │   └── targets
            │       └── action_query_file
            │           └── tasks
            │               └── test_x.yml
            └── unit
                └── plugins
                    └── action
                        └── test_y.py

   1. query_file.py contains my class which extends ActionBase. I use some 
   more modern stuff like types, @singledispatch, and @dataclass. I think it 
   will be hard to support Python 2.7 so I thought I'd stick with Python 3 
   only. Does that decision make sense? I thought so since it's been a while 
   now since Python 2.7 become unsupported.
   2. If I go for Python 3 only, is there something I should do for 
   ansible-test sanity to pass? It complains about some missing Python 
   versions.
   3. Next to as a sibling to query_file.py I have a directory named query. 
   It contains the generic logic which is pure Python and does not require 
   Ansible. I'd like to keep that code split up as it is. Is there a better, 
   more "standard", place for it?
   4. The query directory contains tests as well. I like my tests next to 
   the files being tested, but it seems Ansible prefers a tests directory. 
   Should I move my tests there for them to be executed well in a pipeline?

Thank you very much for taking the time to read this far! I hope there are 
some knowledgable people here who can provide some answers.

/ Kent

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/f90e4595-4eb6-4b0f-ba27-527e59be781en%40googlegroups.com.

Reply via email to