Skip to content

Commit

Permalink
Merge pull request #362 from cradle8810/345_usermod
Browse files Browse the repository at this point in the history
Usermod, zsh, zshrcの自動設定
  • Loading branch information
cradle8810 authored Nov 3, 2024
2 parents af7e278 + 337809f commit 53f91ee
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "templates/all/home/hayato/Source/zshrc"]
path = templates/all/home/hayato/Source/zshrc
url = https://github.com/cradle8810/zshrc
9 changes: 2 additions & 7 deletions inventories/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,12 @@ all:
user:
- name: hayato
username: hayato
password: !vault |
$ANSIBLE_VAULT;1.1;AES256
38396562616338333562613634333436303439626164653362633935653338633163396333633031
3335616530376331643032373961386135666265666366610a623061653731306630386638376136
64376335353461373666373433313462366436373631303436666139336365623263643162653563
3535316564646334350a376361666362643737383539366133363763663162313236643634343437
6564
gid: 1000
uid: 1000
homedir: "/home/hayato"
homedir_mac: "/Users/hayato"
shell: "/usr/bin/zsh"
shell_mac: "/bin/zsh"
samba_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
64373962323533633737623665646132383830653438376263373531623439386666623363363236
Expand Down
6 changes: 6 additions & 0 deletions tasks/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@
file: tasks/all/hayaworld_rootCA.yml
tags:
- ca

- name: "Common / Usermod"
ansible.builtin.import_tasks:
file: tasks/all/usermod.yml
tags:
- users
96 changes: 96 additions & 0 deletions tasks/all/usermod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
- name: "Common / Install zsh (Ubuntu)"
ansible.builtin.apt:
name: "zsh"
state: present
when: ansible_distribution == "Ubuntu"

- name: "Common / Setting Users (Ubuntu)"
no_log: true
when: ansible_distribution == "Ubuntu"
block:
- name: "Common / Usermod (Ubuntu)"
ansible.builtin.user:
name: "{{ item.username }}"
shell: "{{ item.shell }}"
state: "present"
system: true
uid: "{{ item.uid }}"
loop:
"{{ all.vars.user }}"

- name: "Common / Makedir source dir (Ubuntu)"
ansible.builtin.file:
path: "{{ item.homedir }}/Source/zshrc"
state: directory
recurse: true
owner: "{{ item.username }}"
group: "{{ item.username }}"
mode: '0755'
loop:
"{{ all.vars.user }}"

- name: "Common / copy zshrc source directory (Ubuntu)"
ansible.builtin.copy:
src: "templates/all/home/hayato/Source/zshrc/zshrc"
dest: "{{ item.homedir }}/Source/zshrc/zshrc"
mode: '0644'
owner: "{{ item.username }}"
group: "{{ item.username }}"
loop:
"{{ all.vars.user }}"

- name: "Common / Make zshrc symlink to homedir (Ubuntu)"
ansible.builtin.file:
src: "{{ item.homedir }}/Source/zshrc/zshrc"
dest: "{{ item.homedir }}/.zshrc"
owner: "{{ item.username }}"
group: "{{ item.username }}"
state: link
loop:
"{{ all.vars.user }}"

- name: "Common / Setting Users (macOS)"
no_log: true
when: ansible_distribution == "MacOS"
block:
- name: "Common / Usermod (macOS)"
ansible.builtin.user:
name: "{{ item.username }}"
shell: "{{ item.shell_mac }}"
state: "present"
system: true
uid: "{{ item.uid }}"
loop:
"{{ all.vars.user }}"

- name: "Common / Makedir source dir (Ubuntu)"
ansible.builtin.file:
path: "{{ item.homedir_mac }}/Source/zshrc/"
recurse: true
owner: "{{ item.username }}"
group: "{{ item.username }}"
state: directory
mode: '0755'
loop:
"{{ all.vars.user }}"

- name: "Common / mkdir zshrc source directory (macOS)"
ansible.builtin.copy:
src: "templates/all/home/hayato/Source/zshrc/zshrc"
dest: "{{ item.homedir_mac }}/Source/zshrc/zshrc"
mode: '0644'
owner: "{{ item.username }}"
group: "{{ item.username }}"
loop:
"{{ all.vars.user }}"

- name: "Common / Make zshrc symlink to homedir (macOS)"
ansible.builtin.file:
src: "{{ item.homedir_mac }}/Source/zshrc/zshrc"
dest: "{{ item.homedir_mac }}/.zshrc"
owner: "{{ item.username }}"
group: "{{ item.username }}"
state: link
loop:
"{{ all.vars.user }}"
1 change: 1 addition & 0 deletions templates/all/home/hayato/Source/zshrc
Submodule zshrc added at 795efb

0 comments on commit 53f91ee

Please sign in to comment.