Skip to content
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

Offer an include/exclude containers based on a filtering options in the Docker dynamic inventory #610

Closed
b-enoit-be opened this issue Apr 28, 2023 · 2 comments · Fixed by #698
Labels
docker-plain plain Docker (no swarm, no compose, no stack) enhancement New feature or request

Comments

@b-enoit-be
Copy link

b-enoit-be commented Apr 28, 2023

SUMMARY

It would be nice to offer the possibility to exclude certain containers from the dynamic inventory, via a white or black list parameter.

For example, in the amazon.aws.aws_ec2 dynamic inventory, they are proposing two options:

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

community.docker.docker_containers; plugins/inventory/docker_containers.py

ADDITIONAL INFORMATION

It would really be nice to have the same kind of feature as the aws_ec2 dynamic inventory on the Docker one, for example, to exclude; or only include containers with a certain label.

E.g.:

plugin: community.docker.docker_containers
docker_host: unix://var/run/docker.sock

include_filters: 
  ## will only include containers having the custom label 'foo' in the inventory
  ## e.g.: In their Dockerfile,`LABEL my_customer_label=foo`
  - docker_config.Labels.my_custom_label:
    - foo 
@felixfontein felixfontein added enhancement New feature or request docker-plain plain Docker (no swarm, no compose, no stack) labels Jun 27, 2023
@felixfontein
Copy link
Collaborator

The amazon.aws.aws_ec2 options directly translate to API request parameters, so I guess filters can and should look differently here.

This feels like something that should be generally available for all inventory plugins IMO, probably something using Jinja2 expressions that can include/exclude based on random properties returned by the inventory plugin for the host.

@felixfontein
Copy link
Collaborator

I started implementing this in #698.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker-plain plain Docker (no swarm, no compose, no stack) enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants