bertvv / ansible-skeleton Goto Github PK
View Code? Open in Web Editor NEWAn opinionated skeleton for Ansible projects with a development environment powered by Vagrant.
License: MIT License
An opinionated skeleton for Ansible projects with a development environment powered by Vagrant.
License: MIT License
When running vagrant up
, we get an ArgumentError
about the network configuration:
$ vagrant up
/opt/vagrant/embedded/gems/gems/vagrant-2.3.7/plugins/kernel_v2/config/vm.rb:319:in `network': wrong number of arguments (given 2, expected 1) (ArgumentError)
from /home/thomas/source/infra-auto/infra-2223-thomasaelbrecht/vmlab/Vagrantfile:151:in `block (3 levels) in <top (required)>'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/config/v2/loader.rb:37:in `load'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/config/loader.rb:126:in `block (2 levels) in load'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/config/loader.rb:119:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/config/loader.rb:119:in `block in load'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/config/loader.rb:116:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/config/loader.rb:116:in `load'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/vagrantfile.rb:174:in `machine_config'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/environment.rb:983:in `block in find_configured_plugins'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/environment.rb:981:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/environment.rb:981:in `find_configured_plugins'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/environment.rb:1008:in `process_configured_plugins'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/environment.rb:189:in `initialize'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/bin/vagrant:211:in `new'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/bin/vagrant:211:in `<main>'
The solution for this is changing this line:
Line 143 in ce41982
into:
node.vm.network :private_network, **network_options(host)
There are now two script for running a playbook, one for Windows hosts (script runs on the guest, and installs Ansible when necessary), one for Unix-hosts (script runs on host system).
Maybe it would be better to unify this.
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:
ansible-test
and continuous integration with Github ActionsYou 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
Hi @bertvv,
Thank you for an amazing project! I am currently reviewing and noticed that for Windows you are using a custom script because Ansible is not supported on a Windows hosts. I recently discovered that there is a Ansible Local Provisioner that you can use to run Ansible locally.
What are your thoughts on this? I know this project has been out for a while and might have been before the provisioner so I wanted to know if that was the reason or there is another factor that made you chose a custom script.
Again thank you for making this available.
E.g directory structure like:
ansible/roles/
environments/
common/ -> don't know if this will work since it's not an inventory directory
group_vars/
host_vars/
development/
group_vars/
all.yml
webservers.yml
host_vars/
srv001.yml
srv002.yml
inventory -> link to Vagrant inventory?
production/
group_vars/
all.yml
webservers.yml
host_vars/
srv001.yml
srv002.yml
inventory
See http://www.geedew.com/setting-up-ansible-for-multiple-environment-deployments/
download a .repo file and install in /etc/yum.repos.d/
In VirtualBox, create a group for VMs within the same project.
In Vagrantfile:
PROJECT_NAME = '/' + File.basename(Dir.getwd)
[...]
hosts.each do |host|
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--groups', PROJECT_NAME]
end
[...]
I noticed while using runbats.sh
that it is pulling an older version, there are new active maintainers at bats-core while the original repository it is pulling from appears to not have merged anything in quite a while.
Recent Vagrant versions create a private key for each individual host and store it in .vagrant/machines/${HOSTNAME}/virtualbox/private_key
My host OS is windows, so I have to run ansible on the vm I am setting up. This gives me problems when setting up a fedora 24 client, because the version of ansible that gets installed is 2.2.0, which means that your other ansible roles don't fully work anymore
See https://stackoverflow.com/questions/18944855/vagrant-provision-live-output
export PYTHONUNBUFFERED=1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.