apenella / go-ansible

Go-ansible is a Go package that enables the execution of ansible-playbook or ansible commands directly from Golang applications. It supports a wide range of options for each command, enabling smooth integration of Ansible functionality into your projects.
MIT License
905 stars 143 forks source link

Adding feature to Execute the Inventory Command #134

Closed chungeun-choi closed 10 months ago

chungeun-choi commented 10 months ago

Hello go-ansible Contributors!

This is chung-eun, discussing the inventory-related feature (#132). Our project urgently needed this functionality, so I went ahead and developed it.

I'm eager to contribute these developments to the go-ansible project, which is why I've submitted this PR. While I've based my work on the existing contribution guidelines and source code, please don't hesitate to leave comments if there are areas for improvement! ☺️

Inventory

Special Notes

  1. As everyone knows, inventory does not involve actual server connection tasks, so ConnectionOptions and PrivilegeEscalationOptions have been excluded from the properties of ansibleInventoryCmd.
  2. ansibleInventoryOptions: This functionality has been developed based on the official ansible-inventory documentation

I'm not entirely sure which branch this PR should be based on, so I've made the request against the master branch for now. If it needs to be changed, please let me know.

apenella commented 10 months ago

Thank you very much for your contribution @chungeun-choi I will review it during the next few days!

chungeun-choi commented 10 months ago

@apenella Thank you for your reply! I'll be looking forward to your review!

chungeun-choi commented 10 months ago

@apenella Thanks for the feedback. It seems I missed a few things! I'll leave a comment again after I've made the necessary adjustments

chungeun-choi commented 10 months ago

@apenella HI!. I've completed all the tasks you requested and am leaving a comment. While checking, I noticed a few issues and made some modifications. Please refer to the content below!

Requested Items


  1. Addition of the --limit flag functionality and adding test code for it.
  2. Update the README.md to include information about this feature in the packages section.
  3. Add example code for how to use this feature in the examples section.
  4. Modify the review comments left in the test code

Modifications


I apologize for overlooking this feature during development, as it seemed to be a less frequently used one

  1. --vars is not for inputting additional variables, but is used with the --graph flag to show the variable values held by each Host.

    -> As a result, the vaulted encryption process has been removed (related functions deleted, and this item is removed from the test code).

  2. The placement of the 'pattern' was initially set at the end of the command, but this was causing problems in certain situations.

    -> The placement of the 'pattern' value has been moved to follow right after DefaultAnsibleInventoryBinary.

  3. Improved an issue where certain option flags were being set to “nil”.

apenella commented 10 months ago

@chungeun-choi you did a great job with that contribution! Thanks so much!

chungeun-choi commented 10 months ago

@apenella I'm happy that what I've developed can be helpful!