added tmux and all
This commit is contained in:
39
roles/tmux/tasks/main.yml
Normal file
39
roles/tmux/tasks/main.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- name: Install tmux
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
- "tmux"
|
||||
- "git"
|
||||
|
||||
- name: Get all users from /etc/passwd
|
||||
ansible.builtin.getent:
|
||||
database: passwd
|
||||
register: all_users
|
||||
|
||||
- name: Create a list of home directories for bash and zsh users
|
||||
set_fact:
|
||||
user_home_dirs: "{{ user_home_dirs | default([]) + [item.value[4]] }}"
|
||||
loop: "{{ all_users.ansible_facts.getent_passwd | dict2items }}"
|
||||
when: item.value[5] in ['/bin/bash', '/bin/zsh', '/usr/bin/bash', '/usr/bin/zsh', '/usr/bin/fish']
|
||||
|
||||
- name: Display the list of collected home directories
|
||||
ansible.builtin.debug:
|
||||
var: user_home_dirs
|
||||
|
||||
- name: Tmux config Play
|
||||
include_tasks: tmux_config.yml
|
||||
loop: "{{ user_home_dirs }}"
|
||||
|
||||
# ========================================================================
|
||||
# EXAMPLE: Here is how you can reuse the 'user_home_dirs' list
|
||||
# This example task iterates through the list of home directories
|
||||
# and creates a file named 'test.txt' in each directory.
|
||||
# ========================================================================
|
||||
# - name: Example - Create a file in each home directory
|
||||
# ansible.builtin.file:
|
||||
# path: "{{ item }}/test.txt"
|
||||
# state: touch
|
||||
# mode: '0644'
|
||||
# loop: "{{ user_home_dirs }}"
|
||||
Reference in New Issue
Block a user