GithubHelp home page GithubHelp logo

Comments (5)

jseifeddine avatar jseifeddine commented on June 12, 2024 1

Thanks @fosterseth and @AlanCoding for your response...

Is there any way for me to modify the cloned repo to add this in a quick fix ?
Like the invocation of the constrcuted inventory sync job - anything at all ?

Would be fantastic, because at the moment, we're just pasting a massive comma seperate list into the Limit of the job ...

cheers, happy to spend time to investigate if you point me in the right direction :)

What would be ideal - and I'm not really sure why this isn't "a thing" - is using the extra vars -e while building a dynamic inventory... bypassing the constructed inventory

#   MySQL Dynamic Inventory
#   https://github.com/j-oss2023/mysql-dynamic-inventory # Custom Dynamic Plugin
#   
#   Required columns: 
#   'inventory_group', 'inventory_hostname'
#
#   TLDR:
#   Besides the required columns, each column will be assigned 
#   as an ansible hostvar dynamically.

plugin: mysql-dynamic-inventory
db_host: "{{secrets.db_host}}"
db_user: "{{secrets.db_user}}"
db_pass: "{{secrets.db_pass}}"
db_name: "{{secrets.db_name}}"
db_query: |
  SELECT 
    'motorvehicle_co' as inventory_group,
    host as inventory_hostname,
    address as ansible_host,
    account as customer from dealerships
  WHERE customer = "{{target_customer}}"

Then simply calling the playbook like so

ansible-playbook -i per_customer_mysql.yml setup.yml -e 'target_customer="Ferrari"'

That would rock!
But I've read a lot of places that it's simply unattainable ...

Maybe i'm just coming at this at the wrong angle and it's giving me tunnel vision πŸ˜†
But I wish this was possible...

from awx.

jseifeddine avatar jseifeddine commented on June 12, 2024

Please also see:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/constructed_inventory.html#parameter-use_extra_vars

from awx.

fosterseth avatar fosterseth commented on June 12, 2024

@AlanCoding is AWX expected to support the use_extra_vars: True declaration?

from awx.

AlanCoding avatar AlanCoding commented on June 12, 2024

This is a valid point. The problem is that it runs ansible-inventory to save the content to the database before it is used in a job (ansible-playbook) at which time it is re-serialized from the database. There's not a 1-to-1 mapping of constructed inventories to jobs, so there's not a way to make this feature work without breaking other things. Maybe there's some envelope of parameters where it is set to update on launch and the plugin specifics this parameter, it would be okay to apply the job's extra_vars to the constructed inventory.

from awx.

jseifeddine avatar jseifeddine commented on June 12, 2024

Thanks @fosterseth and @AlanCoding for your response...

Is there any way for me to modify the cloned repo to add this in a quick fix ? Like the invocation of the constrcuted inventory sync job - anything at all ?

Would be fantastic, because at the moment, we're just pasting a massive comma seperate list into the Limit of the job ...

cheers, happy to spend time to investigate if you point me in the right direction :)

What would be ideal - and I'm not really sure why this isn't "a thing" - is using the extra vars -e while building a dynamic inventory... bypassing the constructed inventory

#   MySQL Dynamic Inventory
#   https://github.com/j-oss2023/mysql-dynamic-inventory # Custom Dynamic Plugin
#   
#   Required columns: 
#   'inventory_group', 'inventory_hostname'
#
#   TLDR:
#   Besides the required columns, each column will be assigned 
#   as an ansible hostvar dynamically.

plugin: mysql-dynamic-inventory
db_host: "{{secrets.db_host}}"
db_user: "{{secrets.db_user}}"
db_pass: "{{secrets.db_pass}}"
db_name: "{{secrets.db_name}}"
db_query: |
  SELECT 
    'motorvehicle_co' as inventory_group,
    host as inventory_hostname,
    address as ansible_host,
    account as customer from dealerships
  WHERE customer = "{{target_customer}}"

Then simply calling the playbook like so

ansible-playbook -i per_customer_mysql.yml setup.yml -e 'target_customer="Ferrari"'

That would rock! But I've read a lot of places that it's simply unattainable ...

Maybe i'm just coming at this at the wrong angle and it's giving me tunnel vision πŸ˜† But I wish this was possible...

I've fixed the plugin,
#14868 (comment)

which now correctly templates vars in the inventory config file... so that is working now with ansible cli ...

but still - AWX bug fix / feature enhancment is needed to allow it to read those extra vars inside AWX...

from awx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.