Bootstrap Python onto the system

This commit is contained in:
dogeystamp 2022-03-04 07:30:52 -05:00
parent 8eaf39fbd7
commit d7876c6a65
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
5 changed files with 29 additions and 17 deletions

View File

@ -16,6 +16,7 @@
shell: shell:
cmd: "if [[ $(pacman -Q linux | cut -d \" \" -f 2) > $(uname -r) ]]; then echo reboot; fi" cmd: "if [[ $(pacman -Q linux | cut -d \" \" -f 2) > $(uname -r) ]]; then echo reboot; fi"
register: reboot_check register: reboot_check
changed_when: reboot_check.stdout == "reboot"
- name: Reboot for kernel update - name: Reboot for kernel update
reboot: reboot:

View File

@ -7,6 +7,7 @@
pre_tasks: pre_tasks:
- import_tasks: tasks/set_host.yml - import_tasks: tasks/set_host.yml
- import_tasks: tasks/ssh_port.yml - import_tasks: tasks/ssh_port.yml
- import_tasks: tasks/bootstrap.yml
roles: roles:
- role: system - role: system

9
tasks/bootstrap.yml Normal file
View File

@ -0,0 +1,9 @@
- name: Check if Python is present
ping:
ignore_errors: true
register: ping
- name: Bootstrap Python
become: no
raw: "echo root | su -c 'pacman-key --init && pacman-key --populate archlinuxarm && pacman --noconfirm -Syu python' root"
when: ping is failed

View File

@ -2,6 +2,7 @@
local_action: "command ping -c 1 {{ local_ip }}" local_action: "command ping -c 1 {{ local_ip }}"
become: no become: no
ignore_errors: true ignore_errors: true
changed_when: false
register: up_static register: up_static
- name: Switch ansible_host to fallback IP - name: Switch ansible_host to fallback IP

View File

@ -1,42 +1,42 @@
- name: Set default user for SSH - name: Use default credentials for ssh
set_fact: set_fact:
ansible_user: "{{ admin_username }}" ansible_user: "{{ admin_username }}"
- name: Attempt ssh connection - name: Attempt ssh connection
become: no become: no
wait_for_connection: raw: "echo Pong!"
timeout: 10 ignore_unreachable: true
ignore_errors: true changed_when: false
register: ssh_result_default register: ssh_result_default
- name: Set ssh to fallback port - name: Use fallback port for ssh
set_fact: set_fact:
ansible_ssh_port: 22 ansible_ssh_port: 22
when: when:
- ssh_result_default is failed - ssh_result_default is unreachable
- name: Attempt ssh connection - name: Attempt ssh connection
become: no become: no
wait_for_connection: raw: "echo Pong!"
timeout: 10 ignore_unreachable: true
ignore_errors: true changed_when: false
register: ssh_result_port register: ssh_result_port
when: when:
- ssh_result_default is failed - ssh_result_default is unreachable
- name: Set ssh to fallback port and default Arch Linux ARM credentials - name: Use fallback port and default Arch Linux ARM credentials for ssh
set_fact: set_fact:
ansible_ssh_port: "22" ansible_ssh_port: "22"
ansible_user: "alarm" ansible_user: "alarm"
ansible_ssh_password: "alarm" ansible_ssh_password: "alarm"
when: when:
- ssh_result_default is failed - ssh_result_default is unreachable
- ssh_result_port is failed - ssh_result_port is unreachable
- name: Attempt ssh connection - name: Attempt ssh connection
become: no become: no
wait_for_connection: changed_when: false
timeout: 10 raw: "echo Pong!"
when: when:
- ssh_result_default is failed - ssh_result_default is unreachable
- ssh_result_port is failed - ssh_result_port is unreachable