Having a devil of a time writing my first plugin.   The idea is simple, but 
the examples I find are not helping as much as I had hoped.

First off, to make life more interesting,  the plugin is one that is needed 
for a role.  I am trying to write an ansible cookbook to deploy Filebeat. 
 I was able to do this fairly easily on Chef (my first Chef project), but 
Ansible is proving more cantankerous.

So, the problem I am trying to solve is simple, and requires aggregation of 
values.  I found a plugin that will read the contents of a file, and load 
into into a variable value.  I plan to modify this so I can send it a list 
of files, and have it load the contents of ALL the files into a variable.

The problems I am currently struggling with are these:

Where does the plugin go within the role folder hierarchy,  or does it need 
to be global?  I have found various contradictory sources that state it 
goes in "plugins/lookup"  or "lookup_plugins",or  in Ansible root.  Below 
is my heirarchy, and the challenge is that I need to load a list of files 
to load based on the default, membership in groups or instanceID.  That 
list will be built by checking for and loading any group.yaml, EC2ID.yaml 
that exist.  Once I have that list, I need to aggregate the values from the 
corresponding files in the prospectors folders into a variable I can then 
plug into my template.

Ansible doesnt handle aggregation in loops well.  I am looking at one or 
two plugins to do this.  One would be a modification of the example that 
loads a file into a variable to it takes a file list instead.  

   .gitignore
│   filebeat.yml
│   OPS
│   OPS.pub
│   README.md
│
└───roles
    └───filebeat
        │   .travis.yml
        │   LICENSE
        │   README.md
        │
        ├───defaults
        │       main.yml
        │
        ├───handlers
        │       main.yml
        │
        ├───lookup_plugins
        │       hostip.py
        │       prospectors.py
        │
        ├───meta
        │       main.yml
        │
        ├───tasks
        │       debian.yml
        │       main.yml
        │       redhat.yml
        │
        ├───templates
        │       filebeat-config.yml.j2
        │
        ├───tests
        │       inventory
        │       test.yml
        │
        └───vars
            │   default.yaml
            │   main.yml
            │
            ├───groups
            │       filebeaters.yaml
            │       tomcatters.yaml
            │
            ├───instances
            │       i-e4b354f2.yaml
            │
            └───prospectors
                    Base.yaml
                    Tomcat7-Catalina.out.yaml
                    Tomcat7-custom_access.log.yaml
                    Tomcat7-Localhost.log.yaml
                    var_log_openvpn_log.yaml

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a5fe27f2-53b4-411e-bc11-220224012697%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to