mirror of
https://github.com/roles-ansible/ansible_role_sway.git
synced 2024-08-16 13:49:49 +02:00
Optimize playbook workflow without defined username
This commit is contained in:
parent
a7092361c7
commit
612f3326b6
5 changed files with 10 additions and 7 deletions
|
@ -43,7 +43,7 @@ Role Variables
|
|||
i3_applications: []
|
||||
|
||||
*ansible user*
|
||||
i3wm_user: "{{ user }}"
|
||||
i3wm_user: "{{ ansible_user_id }}"
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
|
|
@ -30,15 +30,16 @@
|
|||
owner: "{{ i3wm_user }}"
|
||||
|
||||
- name: register i3 config file
|
||||
action: stat path="~/.config/i3/config"
|
||||
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: ~/.config/i3/config
|
||||
dest: ~/.config/i3/config.bak
|
||||
src: "/home/{{ i3wm_user }}/.config/i3/config"
|
||||
dest: "/home/{{ i3wm_user }}/.config/i3/config.bakup"
|
||||
remote_src: true
|
||||
when: config_file.stat.exists
|
||||
|
||||
|
@ -48,7 +49,7 @@
|
|||
dest: "/home/{{ i3wm_user }}/.config/i3/config"
|
||||
|
||||
- name: check i3 config file
|
||||
command: i3 -C
|
||||
command: "i3 -C -c /home/{{ i3wm_user }}/.config/i3/config"
|
||||
register: check_config_response
|
||||
failed_when: check_config_response.stdout.find('ERROR') != -1
|
||||
rescue:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- hosts: all
|
||||
user: vagrant
|
||||
i3wm_user: vagrant
|
||||
|
||||
vars:
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- hosts: all
|
||||
vars:
|
||||
user: "{{ ansible_user }}"
|
||||
i3wm_user: "{{ ansible_user }}"
|
||||
roles:
|
||||
- travis_test
|
||||
|
|
|
@ -30,3 +30,5 @@ __i3_workspaces:
|
|||
- workspace:
|
||||
id: 0
|
||||
name: " 0 "
|
||||
|
||||
user: "{{ i3wm_user }}"
|
||||
|
|
Loading…
Reference in a new issue