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

67 lines
1.8 KiB
YAML
Raw Normal View History

2017-12-31 00:56:01 +01:00
---
2019-01-19 00:14:00 +01:00
- name: register variables
import_tasks: variables.yml
2017-12-31 00:56:01 +01:00
2018-11-15 15:12:44 +01:00
# ensure i3 packages are installed [Debian].
2017-12-31 00:56:01 +01:00
- include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
2018-11-17 22:46:13 +01:00
# ensure i3 packages are installed [Archlinux}
2018-11-17 22:56:04 +01:00
- include_tasks: setup-Archlinux.yml
2018-11-17 22:46:13 +01:00
when: ansible_os_family == 'Archlinux'
2018-11-15 15:12:44 +01:00
# ensure i3 packages are installed [RHEL].
- include_tasks: setup-RedHat.yml
when: ansible_os_family == 'Fedora' or ansible_os_family == 'RedHat'
2017-12-31 00:56:01 +01:00
# create i3 config file
2018-11-15 15:12:44 +01:00
- name: Creates directory
2019-04-24 12:43:25 +02:00
file:
2019-04-24 09:53:29 +02:00
path: '/home/{{ i3wm_user }}/.config'
2018-11-15 15:12:44 +01:00
state: directory
mode: 0750
2019-04-24 09:53:29 +02:00
owner: "{{ i3wm_user }}"
2018-11-15 15:12:44 +01:00
2017-12-31 00:56:01 +01:00
- name: create i3 config folder
file:
2019-04-24 09:53:29 +02:00
path: '/home/{{ i3wm_user }}/.config/i3/'
2017-12-31 00:56:01 +01:00
state: directory
mode: 0755
2019-04-24 09:53:29 +02:00
owner: "{{ i3wm_user }}"
2017-12-31 00:56:01 +01:00
- name: register i3 config file
action: stat path="/home/{{ i3wm_user }}/.config/i3/config"
2017-12-31 00:56:01 +01:00
register: "config_file"
2017-12-31 00:56:01 +01:00
- 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"
2017-12-31 00:56:01 +01:00
remote_src: true
when: config_file.stat.exists
2018-11-15 15:12:44 +01:00
2017-12-31 00:56:01 +01:00
- name: create i3 config file
template:
src: config.j2
2019-04-24 09:53:29 +02:00
dest: "/home/{{ i3wm_user }}/.config/i3/config"
2018-11-15 15:12:44 +01:00
2017-12-31 00:56:01 +01:00
- name: check i3 config file
command: "i3 -C -c /home/{{ i3wm_user }}/.config/i3/config"
2017-12-31 00:56:01 +01:00
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