Git Product home page Git Product logo

Comments (8)

fredleger avatar fredleger commented on June 12, 2024

Testcase :

Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.box_check_update = false

  config.vm.provision "shell", inline: <<-SHELL
    export DEBIAN_FRONTEND=noninteractive

    echo "+ Installing ansible"
    sudo apt-get install -y software-properties-common
    sudo apt-add-repository ppa:ansible/ansible
    sudo apt-get update -y -q
    sudo apt-get install -y ansible
    sudo bash -c "echo localhost ansible_connection=local >> /etc/ansible/hosts"

    echo "+ checking ansible install"
    ansible --version
    sudo ansible localhost -m ping
    sudo bash -c "grep '/vagrant/roles' /etc/ansible/ansible.cfg || sed -i.bak -e '/#roles_path/a roles_path=/etc/ansible/roles:/vagrant/roles' /etc/ansible/ansible.cfg"

    echo "+ Installing ansible galaxy requirements.yml"
    if  [ -f /vagrant/requirements.yml ]; then sudo ansible-galaxy install -r /vagrant/requirements.yml; fi

    echo "+ Running ansible playbook(s)"
    if [ -f /vagrant/playbook.yml ]; then sudo ansible-playbook --syntax-check /vagrant/playbook.yml && sudo ansible-playbook /vagrant/playbook.yml; fi
 SHELL

end

requirements.yml

---
- src: PeterMosmans.virtualbox-guest

playbook.yml

- hosts: localhost
  become: "yes"
  become_method: "sudo"
  vars:
    - virtualbox_version: "5.0.22"
    - virtualbox_keep: "no"
  roles:
    - PeterMosmans.virtualbox-guest

from ansible-role-virtualbox-guest.

PeterMosmans avatar PeterMosmans commented on June 12, 2024

Great suggestion, thanks. I'll add that to the next version

from ansible-role-virtualbox-guest.

fredleger avatar fredleger commented on June 12, 2024

See PR : #6

from ansible-role-virtualbox-guest.

PeterMosmans avatar PeterMosmans commented on June 12, 2024

FYI @fredleger I'm not sure if you are familiar with it, but as alternative you could also use the inline automatic Ansible provisioner for testing instead of shell script, e.g.:

Vagrant.configure("2") do |config|
  config.vm.box = "debian/jessie64"

[...]

  config.vm.provision "ansible_local" do |ansible|
    ansible.galaxy_role_file = "requirements.yml"
    ansible.inventory_path  = "hosts"
    ansible.install = true
    ansible.install_mode = "pip"
    ansible.limit = "all"
    ansible.playbook = "myplaybook.yml"
  end
end

See e.g. https://www.onwebsecurity.com/devops/zen-provisioning-bootstrap-the-installation-of-ansible-using-vagrant for an example.

from ansible-role-virtualbox-guest.

fredleger avatar fredleger commented on June 12, 2024

Absolutly. But then you relly on the version bundled with the OS wich is 1.7 i guess. Ansible is evolving too fast...

from ansible-role-virtualbox-guest.

fredleger avatar fredleger commented on June 12, 2024

and also you have to use an vagrant box that has ansible installed. I get too much errros doig so, so i switched to this kind of script to setup ansible

from ansible-role-virtualbox-guest.

PeterMosmans avatar PeterMosmans commented on June 12, 2024

Hi @fredleger - personally I have great experiences with the install_mode = "pip" - It installs the latest version ( > 2) automatically. Have you seen the link ? You could use it to bootstrap the installation of an Vagrant Ansible Controller - no previous Ansible version necessary. Anyways, what works best is the main issue 😉

from ansible-role-virtualbox-guest.

fredleger avatar fredleger commented on June 12, 2024

Seems very interisting. will give it a try

from ansible-role-virtualbox-guest.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.