1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_i3wm.git synced 2024-08-16 10:09:53 +02:00
ansible_role_i3wm/tasks/main.yml
2019-06-10 21:56:11 +02:00

78 lines
2.2 KiB
YAML

---
- include_tasks: versioncheck.yml
when: submodules_versioncheck|bool
- name: register variables
import_tasks: variables.yml
# ensure i3 packages are installed [Debian].
- include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
# ensure i3 packages are installed [Archlinux}
- include_tasks: setup-Archlinux.yml
when: ansible_os_family == 'Archlinux'
# ensure i3 packages are installed [RHEL].
- include_tasks: setup-RedHat.yml
when: ansible_os_family == 'Fedora' or ansible_os_family == 'RedHat'
# create i3 config file
- name: Creates directory
file:
path: '/home/{{ i3wm_user }}/.config'
state: directory
mode: 0750
owner: "{{ i3wm_user }}"
- name: create i3 config folder
file:
path: '/home/{{ i3wm_user }}/.config/i3/'
state: directory
mode: 0755
owner: "{{ i3wm_user }}"
- name: register i3 config file
action: stat path="/home/{{ i3wm_user }}/.config/i3/config"
register: "config_file"
- name: backup i3 config file
block:
- name: backup i3 config file if exists
copy:
src: "/home/{{ i3wm_user }}/.config/i3/config"
dest: "/home/{{ i3wm_user }}/.config/i3/config.bakup"
remote_src: true
when: config_file.stat.exists
- name: create i3 config file
template:
src: config.j2
dest: "/home/{{ i3wm_user }}/.config/i3/config"
- name: check i3 config file
command: "i3 -C -c /home/{{ i3wm_user }}/.config/i3/config"
register: check_config_response
failed_when: check_config_response.stdout.find('ERROR') != -1
rescue:
- name: register backup i3 config file
action: stat path="~/.config/i3/config.bak"
register: "config_file_backup"
- name: restore backup file
copy:
src: ~/.config/i3/config.bak
dest: ~/.config/i3/config
remote_src: true
when: config_file_backup.stat.exists
- name: copy files
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- { src: 'files/background.png', dest: "/home/{{ i3wm_user }}/.config/background.png" }
- { src: 'files/lockscreen.png', dest: '/home/{{ i3wm_user }}/.config/lockscreen.png' }
when: i3wm_copy_wallpapers | bool