mirror of
https://github.com/roles-ansible/ansible_role_i3wm.git
synced 2024-08-16 10:09:53 +02:00
Update config validation procedure
This commit is contained in:
parent
3a9bfa57c3
commit
a7d7fc088e
1 changed files with 13 additions and 38 deletions
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
# create i3 config file
|
# create i3 config file
|
||||||
- name: Creates directory
|
- name: Creates directory
|
||||||
|
become: true
|
||||||
|
become_user: "{{ i3wm_user }}"
|
||||||
file:
|
file:
|
||||||
path: '/home/{{ i3wm_user }}/.config'
|
path: '/home/{{ i3wm_user }}/.config'
|
||||||
state: directory
|
state: directory
|
||||||
|
@ -26,50 +28,23 @@
|
||||||
owner: "{{ i3wm_user }}"
|
owner: "{{ i3wm_user }}"
|
||||||
|
|
||||||
- name: create i3 config folder
|
- name: create i3 config folder
|
||||||
|
become: true
|
||||||
|
become_user: "{{ i3wm_user }}"
|
||||||
file:
|
file:
|
||||||
path: '/home/{{ i3wm_user }}/.config/i3/'
|
path: '/home/{{ i3wm_user }}/.config/i3/'
|
||||||
state: directory
|
state: directory
|
||||||
mode: 0755
|
mode: 0755
|
||||||
owner: "{{ i3wm_user }}"
|
owner: "{{ i3wm_user }}"
|
||||||
|
|
||||||
- name: register i3 config file
|
- name: copy and validate i3wm config file
|
||||||
action: stat path="/home/{{ i3wm_user }}/.config/i3/config"
|
become: true
|
||||||
register: "config_file"
|
become_user: "{{ i3wm_user }}"
|
||||||
|
template:
|
||||||
- name: backup i3 config file
|
src: templates/config.j2
|
||||||
block:
|
dest: "/home/{{ i3wm_user }}/.config/i3/config"
|
||||||
|
mode: 0600
|
||||||
- name: backup i3 config file if exists
|
backup: true
|
||||||
copy:
|
validate: i3 -C -c %s
|
||||||
src: "/home/{{ i3wm_user }}/.config/i3/config"
|
|
||||||
dest: "/home/{{ i3wm_user }}/.config/i3/config.bakup"
|
|
||||||
mode: 0600
|
|
||||||
remote_src: true
|
|
||||||
when: config_file.stat.exists
|
|
||||||
|
|
||||||
- name: create i3 config file
|
|
||||||
template:
|
|
||||||
src: config.j2
|
|
||||||
dest: "/home/{{ i3wm_user }}/.config/i3/config"
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- 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
|
|
||||||
mode: 0644
|
|
||||||
when: config_file_backup.stat.exists
|
|
||||||
|
|
||||||
- name: copy files
|
- name: copy files
|
||||||
copy:
|
copy:
|
||||||
|
|
Loading…
Reference in a new issue