Add script, live iso check, and fix some bugs

master
Rasmus Rosengren 3 years ago
parent 45a03fc465
commit a3885fe5ce
Signed by: rsrp
GPG Key ID: A13BC7BC4F81CF5F
  1. 1
      .gitignore
  2. 30
      ansible.sh
  3. 5
      inventory/hosts.yml
  4. 35
      main.yml
  5. 4
      roles/cleanup/tasks/main.yml
  6. 2
      roles/mullvad/tasks/main.yml

1
.gitignore vendored

@ -1,2 +1,3 @@
vars/all.yml
.ssh
inventory

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
if [ ! -f .ssh/id_ed25519.pub ]; then
echo "Generating new ssh key pair..."
ssh-keygen -t ed25519 -f .ssh/id_ed25519 -N ""
fi
echo "Installing dependencies..."
ansible-galaxy install -r requirements.yml
new_ip_addr=true
if [ -f inventory ]; then
current_ip_addr=$(cat inventory | awk 'NR==2')
read -p "Target ip is $current_ip_addr, do you want to change it? (y/N): " res
[[ $res =~ [Yy] ]] || new_ip_addr=false
fi
echo $new_ip_addr
if [ $new_ip_addr ]; then
read -p "Target ip address: " ip_addr
echo "[all]" > inventory
echo $ip_addr >> inventory
fi
exit 1
echo "Running playbook, this may take 5 to 10 minutes..."
ansible-playbook main.yml -k

@ -1,5 +0,0 @@
---
all:
hosts:
<ip_addr>:
ansible_user: root

@ -1,19 +1,36 @@
---
- name: Install system.
hosts: all
roles:
- passwordless_connection
- prep
- disksetup
- configure
user: root
tasks:
- name: Check if live iso.
command: arch-chroot
failed_when: false
register: _check_arch_chroot
changed_when: false
- name: Set arch chroot fact.
set_fact:
is_live_iso: "{{ _check_arch_chroot.rc == 1 }}"
- name: Include tasks.
include_role:
name: "{{ item }}"
with_items:
- passwordless_connection
- prep
- disksetup
- configure
when: is_live_iso
- name: Reboot system
reboot:
when: is_live_iso
- name: Configure system.
hosts: all
user: root
roles:
- kewlfft.aur
@ -34,3 +51,9 @@
- yubikey
- u2f
- cleanup
tasks:
- name: Reboot system.
reboot:
reboot_timeout: 5
failed_when: false

@ -4,6 +4,10 @@
path: /etc/NetworkManager/system-connections/static.nmconnection
state: absent
- name: Read temporary public key.
set_fact:
tmp_pub_key: "{{ lookup('file', '.ssh/id_ed25519.pub') }}"
- name: Remove temporary key from root's authorized_keys.
authorized_key:
state: absent

@ -35,5 +35,5 @@
changed_when: true
- name: Connect.
command: mullvad connect
command: mullvad connect --wait
changed_when: true

Loading…
Cancel
Save