ansible-vm-configure/install-packages.yml
2024-03-08 08:03:36 +10:00

153 lines
4.5 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: Create directory
file:
path: /etc/apt/keyrings
state: directory
- name: Downloading and accepting gpg key
command: wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
args:
creates: /etc/apt/keyrings/gierens.gpg
register: gpg_key_added
- name: accepting GPG key rewriting
command: echo "Y"
when: gpg_key_added.stdout is search("Файл '/etc/apt/keyrings/gierens.gpg' существует. Записать поверх?")
- name: Add repository to source list
lineinfile:
path: /etc/apt/sources.list.d/gierens.list
line: "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main"
become: yes
- name: Modify permissions of files
file:
path: "{{ item }}"
mode: '0644'
with_items:
- /etc/apt/keyrings/gierens.gpg
- /etc/apt/sources.list.d/gierens.list
become: yes
- name: Update apt and install eza
apt:
name: eza
update_cache: yes
state: present
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
...