Open demueller opened 7 years ago
On Wed, Sep 28, 2016 at 11:55:54PM -0700, demueller wrote:
Hello and thank u first for this projekt!
Its actually a feature i would like to ask: for an example when im using ansible with your script:
ansible -i foreman_ansible_inventory.py host1 -m ping
But i would like to set multiply hosts in the command, like: ansible -i foreman_ansible_inventory.py host1 host2 host3 -m ping
Is it possible to do?
Sure. It's the whole point of having a dynamic inventory. Check the generated *.index file for the generated groups (based on e.g. Foremans hostgroups). If you need to define additional groups use params on the host (or domain or whatever) - see the docs.
Great this was exactly that i was looking for:
ansible -i foreman_ansible_inventory.py "host1","host2" -m ping
I there a way to optimize the speed of the execution, cause i have to wait over i minute to get ansible start working. The script is getting a whole list of host from foreman mostly all the time after execution and it takes a lot of time.
> bash ansible.sh
Do 29. Sep 09:13:50 CEST 2016
host1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
host2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
Do 29. Sep 09:15:48 CEST 2016
2016-09-29 09:14:27 [app] [I] Completed 200 OK in 924ms (Views: 791.2ms | ActiveRecord: 81.8ms) 2016-09-29 09:14:27 [app] [I] Started GET "/api/v2/hosts/123/facts?per_page=250&page=1" for 192.168.0.6 at 2016-09-29 09:14:27 +0200 2016-09-29 09:14:27 [app] [I] Processing by Api::V2::FactValuesController#index as JSON 2016-09-29 09:14:27 [app] [I] Parameters: {"per_page"=>"250", "page"=>"1", "apiv"=>"v2", "host_id"=>"123"} 2016-09-29 09:14:27 [app] [I] Authorized user service(service) 2016-09-29 09:14:27 [app] [I] Rendered api/v2/fact_values/index.json.rabl within api/v2/layouts/index_layout (0.8ms) 2016-09-29 09:14:27 [app] [I] Completed 200 OK in 208ms (Views: 21.4ms | ActiveRecord: 30.2ms) 2016-09-29 09:14:27 [app] [I] Started GET "/api/v2/hosts/162?per_page=250&page=1" for 192.168.0.6 at 2016-09-29 09:14:27 +0200 2016-09-29 09:14:27 [app] [I] Processing by Api::V2::HostsController#show as JSON 2016-09-29 09:14:27 [app] [I] Parameters: {"per_page"=>"250", "page"=>"1", "apiv"=>"v2", "id"=>"162"} 2016-09-29 09:14:27 [app] [I] Authorized user service(service) 2016-09-29 09:14:28 [app] [I] Rendered api/v2/hosts/show.json.rabl (833.9ms) 2016-09-29 09:14:28 [app] [I] Completed 200 OK in 903ms (Views: 743.3ms | ActiveRecord: 107.3ms) 2016-09-29 09:14:28 [app] [I] Started GET "/api/v2/hosts/162/facts?per_page=250&page=1" for 192.168.0.6 at 2016-09-29 09:14:28 +0200 2016-09-29 09:14:28 [app] [I] Processing by Api::V2::FactValuesController#index as JSON 2016-09-29 09:14:28 [app] [I] Parameters: {"per_page"=>"250", "page"=>"1", "apiv"=>"v2", "host_id"=>"162"} 2016-09-29 09:14:28 [app] [I] Authorized user service(service) 2016-09-29 09:14:28 [app] [I] Rendered api/v2/fact_values/index.json.rabl within api/v2/layouts/index_layout (0.8ms) 2016-09-29 09:14:28 [app] [I] Completed 200 OK in 173ms (Views: 24.8ms | ActiveRecord: 22.7ms) 2016-09-29 09:14:28 [app] [I] Started GET "/api/v2/hosts/151?per_page=250&page=1" for 192.168.0.6 at 2016-09-29 09:14:28 +0200 2016-09-29 09:14:28 [app] [I] Processing by Api::V2::HostsController#show as JSON
Hello and thank u first for this projekt!
Its actually a feature i would like to ask: for an example when im using ansible with your script:
ansible -i foreman_ansible_inventory.py host1 -m ping
But i would like to set multiply hosts in the command, like:
ansible -i foreman_ansible_inventory.py host1 host2 host3 -m ping
Is it possible to do?
Greets, Denis