Skip to content

Instantly share code, notes, and snippets.

@kentr
Last active December 19, 2017 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kentr/04858cc5854df38d1a4988ee9f153316 to your computer and use it in GitHub Desktop.
Save kentr/04858cc5854df38d1a4988ee9f153316 to your computer and use it in GitHub Desktop.
---
# Ansible playbook to install Vagrant on Fedora.
#
# PREREQUISITES
# 1. Install Ansible:
# ```
# sudo dnf install ansible
# ```
#
# 2. Install Git
#
# 3. Install python dependencies:
# See https://fedoramagazine.org/getting-ansible-working-fedora-23/
# ```
# sudo dnf install -y python2 python2-dnf libselinux-python python-firewall
# ```
#
# ## Reference
#
# * http://fabiorehm.com/blog/2013/04/28/lxc-provider-for-vagrant/
# * https://fedoramagazine.org/getting-ansible-working-fedora-23/
- hosts: localhost
become: yes
# See https://fedoramagazine.org/getting-ansible-working-fedora-23/
gather_facts: false
vars_files:
- vars/main.yml
pre_tasks:
# See https://fedoramagazine.org/getting-ansible-working-fedora-23/
# - name: Install python and deps for ansible modules.
# command: dnf install -y python2 python2-dnf libselinux-python python-firewall
- name: gather facts
setup:
- name: Install firewalld
package:
name: firewalld
when: ansible_os_family == 'RedHat'
roles:
- role: mjanser.vagrant
when: ansible_os_family == 'RedHat'
tasks:
- name: Download later Vagrant.
get_url:
url: "https://releases.hashicorp.com/vagrant/{{ vagrant_version }}/vagrant_{{ vagrant_version }}_x86_64.rpm"
dest: "/tmp/vagrant_{{ vagrant_version }}.rpm"
checksum: "sha256:{{ vagrant_checksum }}"
- name: Install later Vagrant.
command: "rpm -i --force /tmp/vagrant_{{ vagrant_version }}.rpm"
# VIRTUALBOX
- name: Add VirtualBox repo.
command: |
dnf config-manager \
--add-repo \
http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
args:
creates: /etc/yum.repos.d/virtualbox.repo
when: ansible_os_family == 'RedHat'
- name: Update dnf package index.
command: dnf makecache fast
when: ansible_os_family == 'RedHat'
- name: Install VirtualBox
package:
name: "VirtualBox-{{ virtualbox_version }}"
# Experiments
# # DOCKER
# - name: Install Docker dependencies.
# package:
# name: dnf-plugins-core
# when: ansible_os_family == 'RedHat'
#
# - name: Add Docker repo.
# command: |
# dnf config-manager \
# --add-repo \
# https://download.docker.com/linux/fedora/docker-ce.repo
# args:
# creates: /etc/yum.repos.d/docker-ce.repo
# when: ansible_os_family == 'RedHat'
#
# - name: Update dnf package index.
# command: dnf makecache fast
# when: ansible_os_family == 'RedHat'
#
# - name: Install Docker CE.
# package:
# name: docker-ce
#
# - name: Start Docker.
# service:
# name: docker
# state: started
#
# # See https://techoverflow.net/2017/03/01/solving-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/
# - name: Grant ansible user permission to run Docker.
# command: usermod -a -G docker $USER
# become: no
#
# - name: Test Docker installation.
# command: docker run hello-world
# become: no
#
# - name: Install docker-compose.
# command: "curl -L https://github.com/docker/compose/releases/download/{{ docker_composer_version }}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment