ansible-vm-configure/install-packages.yml
2024-03-24 20:31:54 +10:00

156 lines
4.6 KiB
YAML

---
- name: Configure VM
hosts: all
vars_files:
- vars.yml
tasks:
- name: Update apt
ansible.builtin.shell:
cmd: apt update
become: yes
- name: Install packages
apt:
name: "{{ item.name }}"
state: present
loop: "{{ packages_list }}"
become: yes
- name: install Oh-My-Zsh
shell: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
args:
creates: "/home/{{ user_name }}/.oh-my-zsh"
- name: set Zsh was dafault for {{ user_name }}
user:
name: "{{ user_name }}"
shell: /bin/zsh
tags:
- zsh-was-default
become: yes
- name: install Powerlevel10k
git:
repo: https://github.com/romkatv/powerlevel10k.git
dest: "/home/{{ user_name }}/.oh-my-zsh/custom/themes/powerlevel10k"
depth: 1
- name: install plugin Zsh-Syntax-Highlighting
git:
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
dest: "/home/{{ user_name }}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
depth: 1
- name: install plugin Zsh-Autosuggestions
git:
repo: https://github.com/zsh-users/zsh-autosuggestions.git
dest: "/home/{{ user_name }}/.oh-my-zsh/custom/plugins/zsh-autosuggestions"
depth: 1
- name: install plugin Zsh-History-Substring-Search
git:
repo: https://github.com/zsh-users/zsh-history-substring-search.git
dest: "/home/{{ user_name }}/.oh-my-zsh/custom/plugins/zsh-history-substring-search"
depth: 1
- name: copy file .zshrc
copy:
src: data/.zshrc
dest: "/home/{{ user_name }}/.zshrc"
owner: "{{ user_name }}"
group: "{{ user_name }}"
mode: 0644
- name: copy file .p10k.zsh
copy:
src: data/.p10k.zsh
dest: "/home/{{ user_name }}/.p10k.zsh"
owner: "{{ user_name }}"
group: "{{ user_name }}"
mode: 0644
- name: Создание директории /etc/apt/keyrings
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
become: yes
- name: Загрузка и деармирование GPG ключа
ansible.builtin.shell:
cmd: |
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
- name: Добавление репозитория eza в список источников
ansible.builtin.lineinfile:
path: /etc/apt/sources.list.d/gierens.list
line: "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main"
create: yes
become: yes
- name: Установка прав доступа для GPG ключа и списка источников
ansible.builtin.file:
path: "{{ item }}"
mode: '0644'
with_items:
- /etc/apt/keyrings/gierens.gpg
- /etc/apt/sources.list.d/gierens.list
become: yes
- name: Обновление кэша apt
ansible.builtin.apt:
update_cache: yes
become: yes
- name: Установка eza
ansible.builtin.apt:
name: eza
state: present
update_cache: yes
become: yes
- name: Downloading bat-musl_0.24.0_amd64.deb
shell: wget https://github.com/sharkdp/bat/releases/download/v0.24.0/bat-musl_0.24.0_amd64.deb
args:
chdir: "/home/{{ user_name }}"
- name: Downloading bat-musl_0.24.0_amd64.deb
shell: dpkg -i bat-musl_0.24.0_amd64.deb
args:
chdir: "/home/{{ user_name }}"
become: yes
- name: Install bat-musl_0.24.0_amd64.deb
file:
path: "/home/{{ user_name }}/bat-musl_0.24.0_amd64.deb"
state: absent
- name: Downloading duf_0.8.1_linux_amd64.deb
shell: wget https://github.com/muesli/duf/releases/download/v0.8.1/duf_0.8.1_linux_amd64.deb
args:
chdir: "/home/{{ user_name }}"
- name: Install duf_0.8.1_linux_amd64.deb
shell: dpkg -i duf_0.8.1_linux_amd64.deb
args:
chdir: "/home/{{ user_name }}"
become: yes
- name: rm duf_0.8.1_linux_amd64.deb
file:
path: "/home/{{ user_name }}/duf_0.8.1_linux_amd64.deb"
state: absent
- name: create directory /etc/update-motd.d
file:
path: /etc/update-motd.d
state: directory
become: yes
- name: copy 99-mymotd-generator
copy:
src: data/99-mymotd-generator
dest: /etc/update-motd.d/99-mymotd-generator
mode: '0755'
become: yes
...