Wednesday, 17 October 2018

Ansible Playbooks ( automating certain tasks )

tasks/main.yml

---
 - name: copying file with content matching
   copy:
    src: {{ item.name }}
    dest: {{ item.destination }}
   with_items: '{{ fileover }}'
 
 - name: insert string
   lineinfile:
    path: /etc/openvpn/{{ item }}
    regexp: 'remote vpn.eyemagnet.net 1194'
    line: 'remote 202.160.117.202 1194'
    backrefs: yes
   with_items: '{{ vpnpaths }}'

 - name: replace string
   replace:
    path: /etc/openvpn/{{ item }}
    regexp: '1197'
    replace: "1194"
   with_items: '{{ vpnpaths }}'

 - name: Installing packages
   apt:
    name: eyemagnet-rpi-splashscreen
    update_cache: yes
    allow_unauthenticated: yes
    force: yes

vars/main.yml

---
fileover:
  - name: desktop-items-0.conf
    destination: /home/pi/.config/pcmanfm/LXDE-pi
  - name: splash.jpg
    destination: /etc
  - name: config.txt
    destination: /boot
  - name: default.mpegts
    destination: /home/pi
  - name: select-committee
    destination: /var/www
  - name: cmdline.txt
    destination: /boot
  - name: 93eyemagnet_media
    destination: /etc/cron.d
  - name: fstab
    destination: /etc
  - name: rc.local
    destination: /etc

vpnpaths:
  - client-nz.conf
  - client-nz.conf.aws
  - client-nz.conf.nz.vpn

No comments:

Post a Comment