splitting roles
This commit is contained in:
6
roles/cleanup/tasks/main.yml
Normal file
6
roles/cleanup/tasks/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
- name: Remove temporary directory
|
||||||
|
tags: always
|
||||||
|
file:
|
||||||
|
path: "{{ temp_install_dir.path }}"
|
||||||
|
state: absent
|
||||||
|
when: temp_install_dir.path is defined
|
||||||
10
roles/go/tasks/main.yml
Normal file
10
roles/go/tasks/main.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
- name: Install and configure GO
|
||||||
|
tags: go
|
||||||
|
become: true
|
||||||
|
# become_user: "{{ default_user }}"
|
||||||
|
block:
|
||||||
|
- name: Install and configure GO
|
||||||
|
include_role:
|
||||||
|
name: fubarhouse.golang
|
||||||
|
vars:
|
||||||
|
GOPATH: "{{ default_user_home }}/go"
|
||||||
40
roles/python/tasks/main.yml
Normal file
40
roles/python/tasks/main.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
- name: Install and configure Python + tools
|
||||||
|
tags: python
|
||||||
|
become: true
|
||||||
|
become_user: "{{ default_user }}"
|
||||||
|
block:
|
||||||
|
- name: Install Pyenv
|
||||||
|
shell: curl https://pyenv.run | zsh
|
||||||
|
args:
|
||||||
|
creates: "{{ default_user_home }}/.pyenv/bin/pyenv"
|
||||||
|
environment:
|
||||||
|
PYENV_ROOT: "{{ default_user_home }}/.pyenv"
|
||||||
|
|
||||||
|
- name: Install Pyenv version of Python
|
||||||
|
shell: "{{ default_user_home }}/.pyenv/bin/pyenv install {{ pyenv_python_version }}"
|
||||||
|
args:
|
||||||
|
creates: "{{ default_user_home }}/.pyenv/versions/{{ pyenv_python_version }}/bin/python"
|
||||||
|
|
||||||
|
- name: Install pipx
|
||||||
|
command: python3 -m pip install pipx --user
|
||||||
|
args:
|
||||||
|
creates: "{{ default_user_home }}/.local/bin/pipx"
|
||||||
|
|
||||||
|
- name: Install pipx packages
|
||||||
|
shell: "{{ default_user_home }}/.local/bin/pipx install {{ item }}"
|
||||||
|
loop: "{{ pipx_packages }}"
|
||||||
|
|
||||||
|
- name: Install Poetry
|
||||||
|
shell: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
|
||||||
|
args:
|
||||||
|
creates: "{{ default_user_home }}/.poetry/bin/poetry"
|
||||||
|
|
||||||
|
- name: Install Poetry plugin for oh-my-zsh
|
||||||
|
shell: |
|
||||||
|
mkdir {{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry
|
||||||
|
{{ default_user_home }}/.poetry/bin/poetry completions zsh > {{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry/_poetry
|
||||||
|
args:
|
||||||
|
creates: "{{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry"
|
||||||
|
|
||||||
|
- name: Configure Poetry
|
||||||
|
command: "{{ default_user_home }}/.poetry/bin/poetry config virtualenvs.in-project true"
|
||||||
17
roles/rust/tasks/main.yml
Normal file
17
roles/rust/tasks/main.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
- name: Install and configure Rust
|
||||||
|
tags: rust
|
||||||
|
become: true
|
||||||
|
become_user: "{{ default_user }}"
|
||||||
|
block:
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
shell: curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||||
|
args:
|
||||||
|
creates: "{{ default_user_home }}/.cargo/bin/rustup"
|
||||||
|
environment:
|
||||||
|
RUSTUP_HOME: "{{ default_user_home }}/.rustup"
|
||||||
|
CARGO_HOME: "{{ default_user_home }}/.cargo"
|
||||||
|
|
||||||
|
- name: Install base rust programs
|
||||||
|
shell: "{{ default_user_home }}/.cargo/bin/cargo install {{ item }}"
|
||||||
|
loop: "{{ cargo_packages }}"
|
||||||
|
when: install_cargo_packages
|
||||||
32
roles/setup/tasks/main.yml
Normal file
32
roles/setup/tasks/main.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
- name: Initial server setup
|
||||||
|
tags: setup
|
||||||
|
block:
|
||||||
|
- name: Create default user
|
||||||
|
user:
|
||||||
|
name: "{{ default_user }}"
|
||||||
|
password: "{{ default_user_password | password_hash('sha512') }}"
|
||||||
|
groups: sudo
|
||||||
|
create_home: yes
|
||||||
|
shell: /bin/zsh
|
||||||
|
generate_ssh_key: yes
|
||||||
|
ssh_key_bits: 2048
|
||||||
|
ssh_key_file: .ssh/id_rsa
|
||||||
|
update_password: always
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure sudo group has passwordless sudo privileges
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/sudoers
|
||||||
|
state: present
|
||||||
|
regexp: "^%sudo"
|
||||||
|
line: "%sudo ALL=(ALL) NOPASSWD:ALL"
|
||||||
|
validate: "/usr/sbin/visudo -cf %s"
|
||||||
|
|
||||||
|
- name: Upgrade apt packages
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
upgrade: full
|
||||||
|
|
||||||
|
- name: Install apt packages
|
||||||
|
apt:
|
||||||
|
name: "{{ packages_to_install }}"
|
||||||
@@ -1,175 +1,91 @@
|
|||||||
---
|
---
|
||||||
- name: Create default user
|
- name: Configure shell for default user
|
||||||
user:
|
tags: shell
|
||||||
name: "{{ default_user }}"
|
|
||||||
password: "{{ default_user_password | password_hash('sha512') }}"
|
|
||||||
groups: sudo
|
|
||||||
create_home: yes
|
|
||||||
shell: /bin/zsh
|
|
||||||
generate_ssh_key: yes
|
|
||||||
ssh_key_bits: 2048
|
|
||||||
ssh_key_file: .ssh/id_rsa
|
|
||||||
update_password: always
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Ensure sudo group has passwordless sudo privileges
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/sudoers
|
|
||||||
state: present
|
|
||||||
regexp: "^%sudo"
|
|
||||||
line: "%sudo ALL=(ALL) NOPASSWD:ALL"
|
|
||||||
validate: "/usr/sbin/visudo -cf %s"
|
|
||||||
|
|
||||||
- name: Upgrade apt packages
|
|
||||||
apt:
|
|
||||||
update_cache: yes
|
|
||||||
upgrade: full
|
|
||||||
|
|
||||||
- name: Install apt packages
|
|
||||||
apt:
|
|
||||||
name: "{{ packages_to_install }}"
|
|
||||||
|
|
||||||
- name: Get default user home
|
|
||||||
getent:
|
|
||||||
database: passwd
|
|
||||||
key: "{{ default_user }}"
|
|
||||||
split: ":"
|
|
||||||
|
|
||||||
- name: Set default user home
|
|
||||||
set_fact:
|
|
||||||
default_user_home: "{{ getent_passwd[default_user][4] }}"
|
|
||||||
|
|
||||||
- name: Install .tmux.conf to default user
|
|
||||||
copy:
|
|
||||||
src: .tmux.conf
|
|
||||||
dest: "{{ default_user_home }}/.tmux.conf"
|
|
||||||
owner: "{{ default_user }}"
|
|
||||||
group: "{{default_user}}"
|
|
||||||
force: yes
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: Create temporary install directory
|
|
||||||
tempfile:
|
|
||||||
path: "/home/{{ default_user }}"
|
|
||||||
state: directory
|
|
||||||
suffix: .tmp
|
|
||||||
register: temp_install_dir
|
|
||||||
changed_when: false
|
|
||||||
become: true
|
become: true
|
||||||
become_user: "{{ default_user }}"
|
become_user: "{{ default_user }}"
|
||||||
|
block:
|
||||||
|
- name: Get default user home
|
||||||
|
getent:
|
||||||
|
database: passwd
|
||||||
|
key: "{{ default_user }}"
|
||||||
|
split: ":"
|
||||||
|
tags: always
|
||||||
|
|
||||||
- name: Download oh-my-zsh
|
- name: Set default user home
|
||||||
get_url:
|
set_fact:
|
||||||
url: https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
default_user_home: "{{ getent_passwd[default_user][4] }}"
|
||||||
dest: "{{ temp_install_dir.path }}"
|
tags: always
|
||||||
mode: 0777
|
|
||||||
become: true
|
|
||||||
become_user: "{{ default_user }}"
|
|
||||||
|
|
||||||
- name: Install oh-my-zsh
|
- name: Install and configure default user environment
|
||||||
shell: "sh {{ temp_install_dir.path }}/install.sh --unattended"
|
become: true
|
||||||
args:
|
become_user: "{{ default_user }}"
|
||||||
creates: "{{ default_user_home }}/.oh-my-zsh"
|
block:
|
||||||
become: true
|
- name: Install .tmux.conf to default user
|
||||||
become_user: "{{ default_user }}"
|
copy:
|
||||||
|
src: .tmux.conf
|
||||||
|
dest: "{{ default_user_home }}/.tmux.conf"
|
||||||
|
owner: "{{ default_user }}"
|
||||||
|
group: "{{default_user}}"
|
||||||
|
force: yes
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: Install powerlevel10k theme
|
- name: Create temporary install directory
|
||||||
git:
|
tempfile:
|
||||||
repo: "https://gitee.com/romkatv/powerlevel10k.git"
|
path: "/home/{{ default_user }}"
|
||||||
version: master
|
state: directory
|
||||||
dest: "{{ default_user_home }}/.oh-my-zsh/custom/themes/powerlevel10k"
|
suffix: .tmp
|
||||||
depth: 1
|
register: temp_install_dir
|
||||||
|
changed_when: false
|
||||||
|
tags: always
|
||||||
|
|
||||||
- name: Install zsh-syntax-highlighting
|
- name: Download oh-my-zsh
|
||||||
git:
|
get_url:
|
||||||
repo: "https://github.com/zsh-users/zsh-syntax-highlighting.git"
|
url: https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||||
version: master
|
dest: "{{ temp_install_dir.path }}"
|
||||||
dest: "{{ default_user_home }}/.zsh/zsh-syntax-highlighting"
|
mode: 0777
|
||||||
clone: yes
|
|
||||||
update: yes
|
|
||||||
|
|
||||||
- name: Install zsh-autosuggestions
|
- name: Install oh-my-zsh
|
||||||
git:
|
shell: "sh {{ temp_install_dir.path }}/install.sh --unattended"
|
||||||
repo: https://github.com/zsh-users/zsh-autosuggestions
|
args:
|
||||||
version: master
|
creates: "{{ default_user_home }}/.oh-my-zsh"
|
||||||
dest: "{{ default_user_home }}/.zsh/zsh-autosuggestions"
|
|
||||||
clone: yes
|
|
||||||
update: yes
|
|
||||||
|
|
||||||
- name: Install .zshrc to default user
|
- name: Install powerlevel10k theme
|
||||||
template:
|
git:
|
||||||
src: .zshrc.j2
|
repo: "https://gitee.com/romkatv/powerlevel10k.git"
|
||||||
dest: "{{ default_user_home }}/.zshrc"
|
version: master
|
||||||
owner: "{{ default_user }}"
|
dest: "{{ default_user_home }}/.oh-my-zsh/custom/themes/powerlevel10k"
|
||||||
group: "{{ default_user }}"
|
depth: 1
|
||||||
force: yes
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: Install .p10k.zsh to default user
|
- name: Install zsh-syntax-highlighting
|
||||||
copy:
|
git:
|
||||||
src: .p10k.zsh
|
repo: "https://github.com/zsh-users/zsh-syntax-highlighting.git"
|
||||||
dest: "{{ default_user_home }}/.p10k.zsh"
|
version: master
|
||||||
owner: "{{ default_user }}"
|
dest: "{{ default_user_home }}/.zsh/zsh-syntax-highlighting"
|
||||||
group: "{{default_user}}"
|
clone: yes
|
||||||
force: yes
|
update: yes
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: Install Rustup
|
- name: Install zsh-autosuggestions
|
||||||
shell: curl https://sh.rustup.rs -sSf | sh -s -- -y
|
git:
|
||||||
args:
|
repo: https://github.com/zsh-users/zsh-autosuggestions
|
||||||
creates: "{{ default_user_home }}/.cargo/bin/rustup"
|
version: master
|
||||||
environment:
|
dest: "{{ default_user_home }}/.zsh/zsh-autosuggestions"
|
||||||
RUSTUP_HOME: "{{ default_user_home }}/.rustup"
|
clone: yes
|
||||||
CARGO_HOME: "{{ default_user_home }}/.cargo"
|
update: yes
|
||||||
become: true
|
|
||||||
become_user: "{{ default_user }}"
|
|
||||||
|
|
||||||
- name: Install pyenv
|
- name: Install .zshrc to default user
|
||||||
shell: curl https://pyenv.run | zsh
|
template:
|
||||||
args:
|
src: .zshrc.j2
|
||||||
creates: "{{ default_user_home }}/.pyenv/bin/pyenv"
|
dest: "{{ default_user_home }}/.zshrc"
|
||||||
environment:
|
owner: "{{ default_user }}"
|
||||||
PYENV_ROOT: "{{ default_user_home }}/.pyenv"
|
group: "{{ default_user }}"
|
||||||
become: true
|
force: yes
|
||||||
become_user: "{{ default_user }}"
|
mode: 0644
|
||||||
|
|
||||||
- name: Install pyenv version of python
|
- name: Install .p10k.zsh to default user
|
||||||
shell: "{{ default_user_home }}/.pyenv/bin/pyenv install {{ pyenv_python_version }}"
|
copy:
|
||||||
args:
|
src: .p10k.zsh
|
||||||
creates: "{{ default_user_home }}/.pyenv/versions/{{ pyenv_python_version }}/bin/python"
|
dest: "{{ default_user_home }}/.p10k.zsh"
|
||||||
become: true
|
owner: "{{ default_user }}"
|
||||||
become_user: "{{ default_user }}"
|
group: "{{default_user}}"
|
||||||
|
force: yes
|
||||||
- name: Install pipx
|
mode: 0644
|
||||||
command: python3 -m pip install pipx --user
|
|
||||||
args:
|
|
||||||
creates: "{{ default_user_home }}/.local/bin/pipx"
|
|
||||||
become: true
|
|
||||||
become_user: "{{ default_user }}"
|
|
||||||
|
|
||||||
- name: Install poetry
|
|
||||||
shell: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
|
|
||||||
args:
|
|
||||||
creates: "{{ default_user_home }}/.poetry/bin/poetry"
|
|
||||||
become: true
|
|
||||||
become_user: "{{ default_user }}"
|
|
||||||
|
|
||||||
- name: Install poetry plugin for oh-my-zsh
|
|
||||||
shell: |
|
|
||||||
mkdir {{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry
|
|
||||||
{{ default_user_home }}/.poetry/bin/poetry completions zsh > {{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry/_poetry
|
|
||||||
args:
|
|
||||||
creates: "{{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry"
|
|
||||||
become: true
|
|
||||||
become_user: "{{ default_user }}"
|
|
||||||
|
|
||||||
- name: Configure poetry
|
|
||||||
command: "{{ default_user_home }}/.poetry/bin/poetry config virtualenvs.in-project true"
|
|
||||||
become: true
|
|
||||||
become_user: "{{ default_user }}"
|
|
||||||
|
|
||||||
- name: Install base rust programs
|
|
||||||
shell: "{{ default_user_home }}/.cargo/bin/cargo install {{ item }}"
|
|
||||||
loop: "{{ cargo_packages }}"
|
|
||||||
become: true
|
|
||||||
become_user: "{{ default_user }}"
|
|
||||||
|
|||||||
@@ -191,11 +191,17 @@ export PATH="$HOME/.poetry/bin:$PATH"
|
|||||||
################################################################
|
################################################################
|
||||||
source "$HOME/.cargo/env"
|
source "$HOME/.cargo/env"
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# GO #
|
||||||
|
################################################################
|
||||||
|
export GOBIN="$HOME/go/bin"
|
||||||
|
export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# APPS #
|
# APPS #
|
||||||
################################################################
|
################################################################
|
||||||
# AWS
|
# AWS
|
||||||
# complete -C "$HOME/.local/bin/aws_completer" aws
|
complete -C "$HOME/.local/bin/aws_completer" aws
|
||||||
|
|
||||||
# TFEnv
|
# TFEnv
|
||||||
export PATH="$PATH:$HOME/.tfenv/bin"
|
export PATH="$PATH:$HOME/.tfenv/bin"
|
||||||
|
|||||||
19
roles/terraform/tasks/main.yml
Normal file
19
roles/terraform/tasks/main.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
- name: Install and configure Terraform
|
||||||
|
tags: terraform
|
||||||
|
become: true
|
||||||
|
become_user: "{{ default_user }}"
|
||||||
|
block:
|
||||||
|
- name: Install tfenv
|
||||||
|
git:
|
||||||
|
repo: https://github.com/tfutils/tfenv.git
|
||||||
|
version: master
|
||||||
|
dest: "{{ default_user_home }}/.tfenv"
|
||||||
|
depth: 1
|
||||||
|
|
||||||
|
- name: Install latest version of Terraform
|
||||||
|
shell: "{{ default_user_home }}/.tfenv/bin/tfenv install latest"
|
||||||
|
args:
|
||||||
|
creates: "{{ default_user_home }}/.tfenv/version"
|
||||||
|
|
||||||
|
- name: Use latest version of Terraform
|
||||||
|
shell: "{{ default_user_home }}/.tfenv/bin/tfenv use latest"
|
||||||
Reference in New Issue
Block a user