This commit is contained in:
tobi
2022-03-30 22:37:28 +02:00
parent ba8283a7dd
commit 1fd36409b1

View File

@@ -1,111 +1,119 @@
# ---
# - hosts: localhost
# vars:
# - username: sammy
# - home: /home/sammy
# tasks:
# - name: print variables
# debug:
# msg: "Username: {{ username }}, Home dir: {{ home }}"
--- ---
# - name: Basic Arch Linux installation - hosts: localhost
hosts: vars:
localhost: - hostname: 'test-vm'
vars: tasks:
- hostname: 'test-vm' - name: Update and Upgrade all exisiting packages
tasks: community.general.pacman:
- name: Update and Upgrade all exisiting packages update_cache: yes
community.general.pacman: upgrade: yes
update_cache: yes
upgrade: yes
- name: Install basic packages - name: Install basic packages
community.general.pacman: community.general.pacman:
name: sudo,zsh,htop,autoconf,automake,binutils,bison,file,findutils,flex,gawk,gcc,gettext,grep,groff,gzip,libtool,m4,make,patch,pkgconf,sed,texinfo,which,base-devel name: sudo,zsh,htop,autoconf,automake,binutils,bison,file,findutils,flex,gawk,gcc,gettext,grep,groff,gzip,libtool,m4,make,patch,pkgconf,sed,texinfo,which,base-devel
state: present state: present
- name: Make sure we have a 'wheel' group - name: Make sure we have a 'wheel' group
group: group:
name: wheel name: wheel
state: present state: present
- name: Allow 'wheel' to be sudo - name: Allow 'wheel' to be sudo
lineinfile: lineinfile:
dest: /etc/sudoers dest: /etc/sudoers
state: present state: present
regexp: '^%wheel' regexp: '^%wheel'
line: '%wheel ALL=(ALL) ALL' line: '%wheel ALL=(ALL) ALL'
- name: Add the user tobi - name: Add the user tobi
ansible.builtin.user: ansible.builtin.user:
name: tobi name: tobi
password: $6$9OnvBMN6Sxc.muW1$afASAJdoPZL/WxTp6.lh/SurRRiClaru2Pl19fEo6j1aDEQw99kdkfls6.DB8OBacBDnT3bpsLYD3JqrvXlE9/ password: $6$9OnvBMN6Sxc.muW1$afASAJdoPZL/WxTp6.lh/SurRRiClaru2Pl19fEo6j1aDEQw99kdkfls6.DB8OBacBDnT3bpsLYD3JqrvXlE9/
comment: Tobias Maier comment: Tobias Maier
groups: wheel groups: wheel
shell: /bin/zsh shell: /bin/zsh
- name: Add name to git config - name: Add name to git config
community.general.git_config: community.general.git_config:
name: user.name name: user.name
scope: system scope: system
value: Tobias Maier value: Tobias Maier
- name: Add email to git config - name: Add email to git config
community.general.git_config: community.general.git_config:
name: user.email name: user.email
scope: system scope: system
value: admin@maiertobi.de value: admin@maiertobi.de
- name: Create the `aur_builder` user - name: Create the `aur_builder` user
ansible.builtin.user: ansible.builtin.user:
name: aur_builder name: aur_builder
create_home: yes create_home: yes
#group: wheel #group: wheel
- name: Allow the `aur_builder` user to run `sudo pacman` without a password - name: Allow the `aur_builder` user to run `sudo pacman` without a password
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/sudoers.d/11-install-aur_builder path: /etc/sudoers.d/11-install-aur_builder
line: 'aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman' line: 'aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman'
create: yes create: yes
validate: 'visudo -cf %s' validate: 'visudo -cf %s'
- name: Install paru using makepkg if it isn't installed already - name: Install paru using makepkg if it isn't installed already
kewlfft.aur.aur: kewlfft.aur.aur:
name: paru name: paru
use: makepkg use: makepkg
state: present state: present
become: yes become: yes
become_method: su become_method: su
become_user: aur_builder become_user: aur_builder
- name: Install packages from AUR - name: Install packages from AUR
kewlfft.aur.aur: kewlfft.aur.aur:
use: paru use: paru
name: oh-my-zsh-git,zsh-theme-powerlevel10k-git,zsh-autosuggestions,zsh-syntax-highlighting,openssh name: oh-my-zsh-git,zsh-theme-powerlevel10k-git,zsh-autosuggestions,zsh-syntax-highlighting,openssh
state: present state: present
become: yes become: yes
become_user: aur_builder become_user: aur_builder
- name: Clone dotfiles - name: Clone dotfiles
ansible.builtin.git: ansible.builtin.git:
repo: https://gitea.maiertobi.de/tobimai/dotfiles.git repo: https://gitea.maiertobi.de/tobimai/dotfiles.git
dest: /tmp/dotfiles dest: /tmp/dotfiles
- name: Copy zshrc to home dir - name: Copy zshrc to home dir
ansible.builtin.copy: ansible.builtin.copy:
src: //tmp/dotfiles/.zshrc src: //tmp/dotfiles/.zshrc
dest: /home/tobi/.zshrc dest: /home/tobi/.zshrc
owner: tobi owner: tobi
group: tobi group: tobi
mode: '0644' mode: '0644'
- name: Copy p10k to home dir - name: Copy p10k to home dir
ansible.builtin.copy: ansible.builtin.copy:
src: //tmp/dotfiles/.p10k.zsh src: //tmp/dotfiles/.p10k.zsh
dest: /home/tobi/.p10k.zsh dest: /home/tobi/.p10k.zsh
owner: tobi owner: tobi
group: tobi group: tobi
mode: '0644' mode: '0644'
- name: Set a hostname - name: Set a hostname
hostname: hostname:
name: "{{ hostname }}" name: "{{ hostname }}"
# - name: Add ssh-rsa to ssh config as this seems to be disabled by default # - name: Add ssh-rsa to ssh config as this seems to be disabled by default
# blockinfile: # blockinfile:
# path: /etc/ssh/ssh_config # path: /etc/ssh/ssh_config
# block: | # block: |
# Host * # Host *
# HostKeyAlgorithms ssh-rsa # HostKeyAlgorithms ssh-rsa
# PubkeyAcceptedKeyTypes ssh-rsa # PubkeyAcceptedKeyTypes ssh-rsa