--- - name: Prepare scripts for custom VMs (First start) block: - name: Copy files to remote system Debian copy: src: files/first_start_debian.sh dest: /root/first_start.sh owner: root group: root mode: '0644' - name: Edit /etc/rc.local lineinfile: path: /etc/rc.local regexp: '^(exit 0.*)$' line: | chmod 755 /root/first_start.sh | sed 's/^chmod 755 \/root\/first_start.sh.*/\/root\/first_start.sh \&/' -i /etc/rc.local & exit 0 when: ansible_distribution == "Debian" - name: Prepare scripts for custom VMs (First start) block: - name: Copy files to remote system Ubuntu copy: src: files/first_start_ubuntu.sh dest: /root/first_start.sh owner: root group: root mode: '0644' - name: Edit /etc/rc.local lineinfile: path: /etc/rc.local regexp: '^(exit 0.*)$' line: | chmod 755 /root/first_start.sh | sed 's/^chmod 755 \/root\/first_start.sh.*/\/root\/first_start.sh \&/' -i /etc/rc.local & exit 0 when: ansible_distribution == "Ubuntu"