1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_i3wm.git synced 2024-08-16 10:09:53 +02:00

Optimize playbook workflow without defined username

This commit is contained in:
Lilian Roller 2019-04-24 14:49:17 +02:00
parent a7092361c7
commit 612f3326b6
No known key found for this signature in database
GPG key ID: 5215C3441797AB2B
5 changed files with 10 additions and 7 deletions

View file

@ -43,7 +43,7 @@ Role Variables
i3_applications: [] i3_applications: []
*ansible user* *ansible user*
i3wm_user: "{{ user }}" i3wm_user: "{{ ansible_user_id }}"
Example Playbook Example Playbook
---------------- ----------------

View file

@ -30,15 +30,16 @@
owner: "{{ i3wm_user }}" owner: "{{ i3wm_user }}"
- name: register i3 config file - name: register i3 config file
action: stat path="~/.config/i3/config" action: stat path="/home/{{ i3wm_user }}/.config/i3/config"
register: "config_file" register: "config_file"
- name: backup i3 config file - name: backup i3 config file
block: block:
- name: backup i3 config file if exists - name: backup i3 config file if exists
copy: copy:
src: ~/.config/i3/config src: "/home/{{ i3wm_user }}/.config/i3/config"
dest: ~/.config/i3/config.bak dest: "/home/{{ i3wm_user }}/.config/i3/config.bakup"
remote_src: true remote_src: true
when: config_file.stat.exists when: config_file.stat.exists
@ -48,7 +49,7 @@
dest: "/home/{{ i3wm_user }}/.config/i3/config" dest: "/home/{{ i3wm_user }}/.config/i3/config"
- name: check i3 config file - name: check i3 config file
command: i3 -C command: "i3 -C -c /home/{{ i3wm_user }}/.config/i3/config"
register: check_config_response register: check_config_response
failed_when: check_config_response.stdout.find('ERROR') != -1 failed_when: check_config_response.stdout.find('ERROR') != -1
rescue: rescue:

View file

@ -1,6 +1,6 @@
--- ---
- hosts: all - hosts: all
user: vagrant i3wm_user: vagrant
vars: vars:

View file

@ -1,6 +1,6 @@
--- ---
- hosts: all - hosts: all
vars: vars:
user: "{{ ansible_user }}" i3wm_user: "{{ ansible_user }}"
roles: roles:
- travis_test - travis_test

View file

@ -30,3 +30,5 @@ __i3_workspaces:
- workspace: - workspace:
id: 0 id: 0
name: " 0 " name: " 0 "
user: "{{ i3wm_user }}"