ansible-skeleton icon indicating copy to clipboard operation
ansible-skeleton copied to clipboard

Vagrantfile module for Ansible based on your work with modifications that may interest you

Open jclaveau opened this issue 4 years ago • 1 comments
trafficstars

Hello!

Needing to control Vagrant from Ansible roles or playbooks (for cluster testing purpose), I had to write a collection of modules to handle Vagrant commands and Vagrantfile. For this second part, your work is the best I found during my tech monitoring so I integrated some of it in mine.

Here is my collection repo: https://github.com/jclaveau/ansible-vagrant-modules

To be les opiniated as you, I had to modify some parts of your code:

  • Support of multiple provisionners with all their possible parameters
  • Support of all possible parameters for forwarded_ports (makes overwriting of ssh ports possible)
  • Optional vagrant-groups.yml file
  • Warning removal due to Ruby's ** splat operator
  • Tests with ansible-test and continuous integration with Github Actions

You can find these modifications here: https://github.com/jclaveau/ansible-vagrant-modules/blob/main/plugins/module_utils/Vagrantfile

It diverged quite a lot so I cannot really make a PR but I wanted to notice you of my work so you may take value from it. Thus I open this bug.

I kept the MIT licensed only for the Vagrantfile so you can use it as much as you want. The rest of my collection is in GPLv3+ as the Ansible module development guidelines requires. Obviously, I listed your contributors in the credits of my README.

Thanks a lot for your work!

Here is an example of use (You can see how Ansible yaml fits well with your yaml config):

- name: Add a vm to the Vagrantfile
  jclaveau.vagrant.config:
  args:
    state: "present"
    name: "{{ item }}"
    config:
      box: boxomatic/debian-11
      ansible:
        playbook: "glusterfs_provisionning_playbook.yml"
      shell:
        inline: 'echo "provisionning done"'
      forwarded_ports:
        - host: "808{{ i }}"
          guest: 80
        - host: "8{{ i }}43"
          guest: 443
    loop:
     - srv001
     - srv002
  loop_control:
    index_var: "i"

Thanks a lot for your work

jclaveau avatar Jun 19 '21 12:06 jclaveau

So sorry for not responding earlier. I'm a bit overwhelmed with Github notifications on all my repos...

Very cool! I'm so glad you got use out of my Vagrantfile & thanks for letting me know!

I'll be checking your changes when I have some time & see what could be a useful addition.

bertvv avatar Oct 08 '21 11:10 bertvv