Skip to content

Instantly share code, notes, and snippets.

@kwbr kwbr/Vagrantfile
Created Jun 22, 2018

Embed
What would you like to do?
Example: apt_repository rewrites sources.list #41647

FIRST RUN

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [template] ****************************************************************
changed: [default]

TASK [apt_repository] **********************************************************
changed: [default]

PLAY RECAP *********************************************************************
default                    : ok=3    changed=2    unreachable=0    failed=0  

New file dropped into sources.list.d

$ ls -l /etc/apt/sources.list.d
total 4
-rw-r--r-- 1 root root 72 Jun 22 07:37 ftp_de_debian_org_debian.list

Template applied

$ cat /etc/apt/sources.list
# 
# Ansible managed
# 

deb http://ftp.de.debian.org/debian/ stretch main non-free contrib

SECOND RUN // CHECK MODE + DIFF

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [template] ****************************************************************
--- before: /etc/apt/sources.list
+++ after: /home/kai/.ansible/tmp/ansible-local-6785m24lesvc/tmpn5kxzj4s/sources.list.j2
@@ -1,5 +1,5 @@
-# 
+#
 # Ansible managed
-# 
+#
 
 deb http://ftp.de.debian.org/debian/ stretch main non-free contrib

changed: [default]

TASK [apt_repository] **********************************************************
ok: [default]

PLAY RECAP *********************************************************************
default                    : ok=3    changed=1    unreachable=0    failed=0   

THIRD RUN

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [template] ****************************************************************
changed: [default]

TASK [apt_repository] **********************************************************
ok: [default]

PLAY RECAP *********************************************************************
default                    : ok=3    changed=1    unreachable=0    failed=0   
---
- hosts: all
become: true
tasks:
- template:
src: ./sources.list.j2
dest: /etc/apt/sources.list
- apt_repository:
repo: deb http://ftp.de.debian.org/debian/ experimental main non-free contrib
state: present
{{ ansible_managed | comment }}
deb http://ftp.de.debian.org/debian/ stretch main non-free contrib
Vagrant.configure("2") do |config|
config.vm.box = "debian/stretch64"
config.vm.provision "ansible" do |ansible|
ansible.compatibility_mode = "2.0"
ansible.playbook = "play.yml"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.