Changeset - c3309581c2ac
.gitmodules
Show inline comments
 
new file 100644
 
[submodule "roles/initial/files"]
 
	path = roles/initial/files
 
	url = ssh://kallithea@projects.c3l.lu/ChaosStuff/cnc-host-keys
README.md
Show inline comments
 
new file 100644
 
# Command and Control
 
These scripts automate the Command and Control SBC installation as much as possible.
 

	
 
Note that git submodules **must** be initalized, they contain crucial information such as
 
the SSH host keys and the public key of autom8. Special access is needed.
 

	
 
## How to use
 
Flash the image on the eMMC using the flashEMMC.sh script (see section).
 
Then use ansible.sh to install and configure the installation.
 

	
 
### Structure of submodule
 
```
 
files
 
├── autom8_public_key
 
├── mcr-alpha
 
│   └── ssh_host_*
 
├── mcr-beta
 
│   └── ssh_host_*
 
├── mcr-delta
 
│   └── ssh_host_*
 
└── mcr-gamma
 
    └── ssh_host_*
 
```
 

	
 
## Requirements
 
- Ansible (+ requirements.txt)
 
- expect
 
- sshpass
 
- OpenSSH tools (ssh-keygen, ssh-copy-id)
 

	
 
## Scripts
 
There are various scripts, some of which are supposed to be used directly, while others are used by Ansible itself.
 

	
 
### flashEMMC.sh
 
Usage: 
 
`sudo ./flashEMMC.sh [block device name, e.g. sdb]`
 

	
 
This script automates the installation of the ArchLinuxARM ODROID C2 image. (as shown on the [ALARM installation page](https://archlinuxarm.org/platforms/armv8/amlogic/odroid-c2#installation))
 

	
 
It shows the user information about the block device they indicated, asking if it is the right device. If it is, all mounts related to this block device are unmounted, a couple of blocks at the start are zero-ed out, the partition table is created, the single partition's FS is created, the ALARM image downloaded, hash verified, the parition is mounted, the tarball extracted, then the bootloader is installed. Finally, everything is `sync`-ed, and the directory unmounted.
 
### ansible.sh
 
Usage: 
 
`sudo ./ansible.sh [playbook file, if none, site.yml]`
 

	
 
It simply verifies that the ansible requirements.txt are met and runs through the specific playbook.
alpha.yml
Show inline comments
 
new file 100644
 
---
 
- name: Create local key and deploy it
 
  hosts: mcr-alpha
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - localKey
 

	
 
- name: Install python
 
  hosts: mcr-alpha
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - python
 

	
 
- name: Setup pi
 
  hosts: mcr-alpha
 
  remote_user: alarm
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - initial
 

	
 
- name: Setup kiosk
 
  hosts: mcr-alpha
 
  remote_user: odroid
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - kiosk
ansible.sh
Show inline comments
 
new file 100755
 
ansible-galaxy install -r requirements.yml
 

	
 
if [ -z ${1+x} ]; then
 
	echo "var is unset"; 
 
	PLAYBOOK=site.yml
 
else
 
	PLAYBOOK=$1
 
fi
 

	
 
# Agent running causes issues because SSH seems to prioritise those keys by default
 
SSH_AUTH_SOCK=/dev/null
 
ansible-playbook -v -i hosts.yml $PLAYBOOK
beta.yml
Show inline comments
 
new file 100644
 
---
 
- name: Create local key and deploy it
 
  hosts: mcr-beta
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - localKey
 

	
 
- name: Install python
 
  hosts: mcr-beta
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - python
 

	
 
- name: Setup pi
 
  hosts: mcr-beta
 
  remote_user: alarm
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - initial
 

	
 
- name: Setup kiosk
 
  hosts: mcr-beta
 
  remote_user: odroid
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - kiosk
delta.yml
Show inline comments
 
new file 100644
 
---
 
- name: Create local key and deploy it
 
  hosts: mcr-delta
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - localKey
 

	
 
- name: Install python
 
  hosts: mcr-delta
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - python
 

	
 
- name: Setup pi
 
  hosts: mcr-delta
 
  remote_user: alarm
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - initial
 

	
 
- name: Setup kiosk
 
  hosts: mcr-delta
 
  remote_user: odroid
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - kiosk
flashEMMC.sh
Show inline comments
 
new file 100755
 
#!/usr/bin/env bash
 
DEV=$1
 
IMAGE_NAME=ArchLinuxARM-odroid-c2-latest.tar.gz
 
# Fast mirror, but I'm not sure we can trust it...
 
DOWNLOAD_LINK=https://mirrors.dotsrc.org/archlinuxarm/os/
 
HASH_LINK=https://de3.mirror.archlinuxarm.org/os/
 

	
 

	
 
checkRoot() {
 
	[ `id -u` -eq 0 ] || { echo "Run script (as root) or (with sudo)"; exit 1; }
 
}
 

	
 
diskInfo() {
 
	[[ -e /dev/$DEV ]] || { echo "ERROR: Drive doesn't exist" && exit 1; }
 
	fdisk -l /dev/$DEV
 
	echo
 
}
 

	
 
verifyRightDrive() {
 
	sleep 3
 
	read -n 1 -r -p "Is this the right drive? [y/N] " response
 
	if [[ "$response" =~ ^([yY])$ ]]
 
	then
 
		return 0
 
	else
 
		echo
 
		exit 1
 
	fi
 
}
 

	
 
umountInitially() {
 
	BLKDEVS=$(find /dev/ -name ${DEV}*)
 
	for LINE in $BLKDEVS; do
 
		sudo umount $LINE
 
	done
 
}
 

	
 
zeroBeginning() {
 
	dd if=/dev/zero of=/dev/$DEV bs=1M count=8
 
}
 

	
 
partitionEMMC() {
 
fdisk -W always /dev/$DEV << EOF
 
o
 
n
 
p
 
1
 

	
 

	
 

	
 
w
 
EOF
 
}
 

	
 
createEXT4fs() {
 
	mkfs.ext4 -O ^metadata_csum,^64bit /dev/${DEV}1
 
}
 

	
 
cdToScript() {
 
	TMP=$(dirname "$0")
 
	cd $TMP
 
	mkdir flashEMMC
 
	cd flashEMMC
 
}
 

	
 
unmountFS() {
 
	umount root
 
}
 

	
 
panic() {
 
	cdToScript
 
	unmountFS
 
	exit 1
 
}
 

	
 
downloadImage() {
 
	rm ${IMAGE_NAME}
 
	wget ${DOWNLOAD_LINK}${IMAGE_NAME}
 
	wget ${HASH_LINK}${IMAGE_NAME}.md5
 
	md5sum -c ${IMAGE_NAME}.md5 || { echo "Hash of image is incorrect"; panic; }
 
}
 

	
 
extractImage() {
 
	bsdtar -xpf ArchLinuxARM-odroid-c2-latest.tar.gz -C root
 
}
 

	
 
mountFS() {
 
	mkdir root
 
	mount /dev/${DEV}1 root
 
	[ -e ${IMAGE_NAME}.md5 ] && md5sum -c ${IMAGE_NAME}.md5 || downloadImage && extractImage
 
}
 

	
 
flashBootloader() {
 
	cd root/boot
 
	./sd_fusing.sh /dev/${DEV}
 
	cd ../..
 
}
 

	
 

	
 
main() {
 
	checkRoot
 
	diskInfo
 
	verifyRightDrive
 
	umountInitially
 
	zeroBeginning
 
	partitionEMMC
 
	createEXT4fs
 
	cdToScript
 
	mountFS
 
	flashBootloader
 
	unmountFS
 
}
 

	
 
main
gamma.yml
Show inline comments
 
new file 100644
 
---
 
- name: Create local key and deploy it
 
  hosts: mcr-gamma
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - localKey
 

	
 
- name: Install python
 
  hosts: mcr-gamma
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - python
 

	
 
- name: Setup pi
 
  hosts: mcr-gamma
 
  remote_user: alarm
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - initial
 

	
 
- name: Setup kiosk
 
  hosts: mcr-gamma
 
  remote_user: odroid
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - kiosk
hosts.yml
Show inline comments
 
new file 100644
 
all:
 
  children:
 
    cnc:
 
      vars:
 
        ansible_ssh_private_key_file: "{{inventory_dir}}/sshKey"
 
        ansible_ssh_public_key_file: "{{inventory_dir}}/sshKey.pub"
 
        ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
 
      children:
 
        cncServer:
 
          hosts:
 
            mcr-alpha:
 
              ansible_host: mcr-alpha.lan
 
              barrierCommand: 'barriers --config /home/odroid/barrierConfiguration --name mcr-alpha --disable-crypto -f'
 
              dashboardUrl: 'http://roonadan.lan/d/1i0gquEmz/turris?orgId=1&refresh=30s'
 
        cncClient:
 
          vars:
 
            barrierCommand: 'barrierc --disable-crypto -f mcr-alpha'
 
          hosts:
 
            mcr-gamma:
 
              ansible_host: mcr-gamma.lan
 
              dashboardUrl: 'http://roonadan.lan/d/hfvfaCyik/mqtt?orgId=1&refresh=30s'
 
            mcr-delta:
 
              ansible_host: mcr-delta.lan
 
              dashboardUrl: 'http://roonadan.lan/d/tI2qaTEiz/odroid?orgId=1&refresh=30s'
 
            mcr-beta:
 
              ansible_host: mcr-beta.lan
 
              dashboardUrl: 'http://roonadan.lan/d/OsA71lsiz/spaceapi?orgId=1&refresh=30s'
init.sh
Show inline comments
 
new file 100755
 
generateKey() {
 
	touch sshKey
 
	touch sshKey.pub
 
	rm sshKey
 
	rm sshKey.pub
 
	ssh-keygen -t ed25519 -f ./sshKey -q -N "" -C ""
 
}
 

	
 
deployKey() {
 
	sshpass -p alarm ssh-copy-id -i ./sshKey.pub -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PubkeyAuthentication=false alarm@$1
 
}
 

	
 
# If keys are present, we just need to deploy it and destroy the SSH Agent
 
# Otherwise, we genrate a key and then deploy it
 
# The key can be present on the remote host multiple times,
 
# -> not a big issue, just not clean, but it works
 
[ -e sshKey ] && [ -e sshKey.pub ] || generateKey
 

	
 

	
 
for remoteHost in "$@"
 
do
 
    echo "$remoteHost"
 
    deployKey "$remoteHost"
 
done
 

	
 
export SSH_AUTH_SOCK=/dev/null
requirements.yml
Show inline comments
 
new file 100644
 
collections:
 
  - name: kewlfft.aur
roles/initial/files
Show inline comments
 
new file 160000
 
Subproject commit 845d64cadf0a414b2e2abd4147e2ee13a3105efb
roles/initial/tasks/aur.yml
Show inline comments
 
new file 100644
 
---
 
# https://gist.github.com/cahna/45bb9eee92c5f1fce66f
 
- name: AUR | get metadata from AurJson api
 
  connection: local
 
  sudo: no
 
  uri: >
 
    url=https://aur.archlinux.org/rpc.php?type=info&arg={{ pkg_name | mandatory }}
 
    return_content=yes
 
    timeout=6
 
  register: api_info
 

	
 
- assert:
 
    that:
 
      - api_info.status == 200
 
      - api_info.json is defined
 
      - api_info.json.type == 'info'
 
      - api_info.json.resultcount == 1
 
      - api_info.json.results is defined
 

	
 
- name: AUR | {{ pkg_name }} | download tarball
 
  sudo: no
 
  connection: local
 
  get_url: >
 
    url='https://aur.archlinux.org{{ api_info.json.results.URLPath }}'
 
    dest='/tmp/'
 
  register: aur_tarball
 

	
 
- name: AUR | {{ pkg_name }} | upload tarball to host and extract it
 
  sudo: yes
 
  sudo_user: "{{ makepkg_nonroot_user }}"
 
  unarchive: >
 
    src={{ aur_tarball.dest }}
 
    dest=/tmp/
 
  register: extracted_pkg
 

	
 
# This will break if run as root. Set user to use with makepkg with 'makepkg_user' var
 
- name: AUR | {{ pkg_name }} | build package, including missing dependencies
 
  when: extracted_pkg | changed
 
  sudo: yes
 
  sudo_user: "{{ makepkg_nonroot_user }}"
 
  command: >
 
    makepkg --noconfirm --noprogressbar -mfs
 
    chdir=/tmp/{{ pkg_name }}
 
  register: aur_makepkg_result
 

	
 
# Shameless variable declaration hack
 
- shell: ls -1 /tmp/{{ pkg_name | quote }} | grep pkg.tar
 
  register: compiled_package_name
 

	
 
- name: AUR | {{ pkg_name }} | install newly-built aur package with pacman
 
  when: aur_makepkg_result | changed
 
  sudo: yes
 
  shell: >
 
    pacman --noconfirm --noprogressbar --needed -U {{ compiled_package_name.stdout | quote }}
 
    chdir=/tmp/{{ pkg_name }}
 
  register: pacman_install_result
 
  changed_when: pacman_install_result.stdout is defined and pacman_install_result.stdout.find('there is nothing to do') == -1
roles/initial/tasks/main.yml
Show inline comments
 
new file 100644
 
# This role copies over the right SSH host keys, sets up some tools and creates the users
 
- name: Set up host ssh keys
 
  import_tasks: ssh_host.yml
 
- name: Update system
 
  become: yes
 
  become_method: su
 
  become_user: "root"
 
  vars:
 
    ansible_become_pass: root
 
  community.general.pacman:
 
    update_cache: yes
 
    upgrade: yes
 
- name: Install basic tools (sudo, vim, etc.)
 
  import_tasks: tools.yml
 
- name: Create users
 
  import_tasks: users.yml
 
- name: Change hostname
 
  become: yes
 
  become_method: su
 
  become_user: "root"
 
  vars:
 
    ansible_become_pass: root
 
  ansible.builtin.hostname:
 
    name: "{{ inventory_hostname }}"
roles/initial/tasks/ssh_host.yml
Show inline comments
 
new file 100644
 
# This task list copies over the right SSH host keys
 
# https://linuxdigest.com/howto/ansible-copy-multiple-files/
 
# https://stackoverflow.com/questions/53102214/ansible-how-can-i-copy-files-to-hosts-depending-on-group-membership
 
# https://stackoverflow.com/questions/70378717/ansible-how-to-delete-files-starting-with-a-specific-name
 
---
 
- name: Setup ssh keys as root
 
  become: yes
 
  become_method: su
 
  become_user: "root"
 
  vars:
 
    ansible_become_pass: root
 
  block:
 
    - name: List existing host keys
 
      ansible.builtin.find:
 
        paths: /etc/ssh/
 
        patterns: "^ssh_host_.+$"
 
        use_regex: true
 
      register: ssh_host_keys
 

	
 
    - name: Delete existing host keys
 
      ansible.builtin.file:
 
        state: absent
 
        path: "{{ item }}"
 
      loop: "{{ ssh_host_keys.files|map(attribute='path')|list }}"
 

	
 
    - name: Copy SSH host keys
 
      ansible.builtin.copy:
 
        src: "{{ inventory_hostname }}/"
 
        dest: /etc/ssh
 
        owner: root
 
        group: root
 
        mode: '600'
 

	
 
    - name: List public host keys
 
      ansible.builtin.find:
 
        paths: /etc/ssh/
 
        patterns: "^ssh_host_.+_pub$"
 
        use_regex: true
 
      register: ssh_host_keys_pub
 

	
 
    - name: change visibility of host public keys
 
      ansible.builtin.file:
 
        path: "{{ item }}"
 
        mode: '644'
 
      loop: "{{ ssh_host_keys_pub.files|map(attribute='path')|list }}"
roles/initial/tasks/tools.yml
Show inline comments
 
new file 100644
 
# This task list sets up the basic tools
 
---
 
- name: Install basic tools
 
  become: yes
 
  become_method: su
 
  become_user: "root"
 
  vars:
 
      ansible_become_pass: root
 
  block:
 
    - name: Update pacman cache and update
 
      community.general.pacman:
 
        update_cache: no
 
        upgrade: yes
 

	
 
    - name: Install tools
 
      community.general.pacman:
 
        state: installed
 
        name:
 
          - sudo
 
          - vim
 
          - htop
 
          - base-devel
 
          - git
 

	
 
    - name: Enable sudo for wheel
 
      ansible.builtin.lineinfile:
 
        path: /etc/sudoers
 
        state: present
 
        line: '%wheel ALL=(ALL:ALL) NOPASSWD: ALL'
 
        validate: /usr/sbin/visudo -cf %s
 

	
 
    - name: Add default user to wheel group
 
      ansible.builtin.user:
 
        name: "{{ ansible_user }}"
 
        append: yes
 
        groups: wheel
 

	
 
- name: Install paru
 
  block:
 
    - name: Gather package facts
 
      ansible.builtin.package_facts:
 
        manager: pacman
 

	
 
    - name: Install paru if not already installed
 
      when: "'paru-bin' not in ansible_facts.packages"
 
      block:
 
        - name: Install necessary tools
 
          become: yes
 
          become_method: su
 
          become_user: "root"
 
          vars:
 
            ansible_become_pass: root
 
          community.general.pacman:
 
            state: installed
 
            name:
 
              - base-devel
 
              - git
 

	
 
        - name: Install paru
 
          kewlfft.aur.aur:
 
            name: paru-bin
 
            use: makepkg
 
            state: present
roles/initial/tasks/users.yml
Show inline comments
 
new file 100644
 
# This task list sets up the needed users
 
---
 
- name: Create users
 
  become: yes
 
  become_method: su
 
  become_user: "root"
 
  vars:
 
    ansible_become_pass: root
 
  block:
 
    - name: Standard user
 
      vars:
 
        username: odroid
 
      block:
 
        - name: Create user
 
          ansible.builtin.user:
 
            name: "{{ username }}"
 
            create_home: yes
 
            append: yes
 
            groups: wheel, video
 
            state: present
 
            password: "{{ username | password_hash('sha512') }}"
 
            shell: "/bin/bash"
 
        - name: Add ssh key to odroid
 
          ansible.posix.authorized_key:
 
            user: "{{ username }}"
 
            key: "{{ lookup('file', ansible_ssh_public_key_file) }}"
 

	
 
    - name: autom8 user
 
      vars:
 
        username: autom8
 
      block:
 
        - name: Create user
 
          ansible.builtin.user:
 
            name: "{{ username }}"
 
            create_home: yes
 
            state: present
 

	
 
        - name: add SSH key
 
          ansible.posix.authorized_key:
 
            user: "{{ username }}"
 
            state: present
 
            key: "{{ lookup('file', 'autom8_public_key') }}"
 
            manage_dir: yes
 

	
 
        - name: allow shutting down
 
          ansible.builtin.lineinfile:
 
            path: /etc/sudoers
 
            state: present
 
            line: 'ALL ALL=NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff, /sbin/shutdown now'
 
            validate: /usr/sbin/visudo -cf %s
roles/kiosk/files/agettyAutologin
Show inline comments
 
new file 100644
 
[Service]
 
ExecStart=
 
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin odroid %I $TERM
roles/kiosk/files/barrier/SSL/Barrier.pem
Show inline comments
 
new file 100644
 
-----BEGIN PRIVATE KEY-----
 
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDH2UqcaAlEAZMV
 
3N2/jUd5tOkMTGqmqs9st9afk7b2EjNLffit3ck+M3dt6RfOU0tf54bAX7fXYcpG
 
tD4WyZ019u5qlfGnQCeJMFYNGdBSpX/mlp9mjC7yv18OIBOv87rCgA7YBjoXzkA9
 
XCDxW/+4RGwJZVeDx4U45ECRupbzIaCmpJdPqnzkcPPwXi64F9RwfyuQENImRkMP
 
x/hrbWeYOCaTGHA9730MFoqz+xIgDJ0mHVAnGy/I0caFqhqW5lVzDh02Cw7DGF0o
 
1ZIA2f/n1h668+74npHngld3cD829kdDJAKHAJTrca0tGjlUjhrDS7WYc5X+mvKm
 
Xc2LbIYBAgMBAAECggEBAKgozaAn5kwD6yjFTQ2GKnNdZ4+CqWcOaTT4x65E0/ng
 
PKs0F1DtQw2EruSb8v0Yl17eaUNsBzxDO7ocpfX0tcUXv2uOOeValSnZsz6YzvML
 
8UAs03mtUT/PCYPQN+Cg/C/3IwZgzvcDBIjdAZc1q0n4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UGoAxBUbwNiVOQbaUaCOqNZlr3A7
 
hUOc1m+B6brCEvl7H5k2HDtiW9fzfmaoQ9qdiUIHVzsXVmoqiVcEP1uiK54EFTeQ
 
PZnULIlz5zfx
 
-----END CERTIFICATE-----
roles/kiosk/files/barrier/SSL/Fingerprints/Local.txt
Show inline comments
 
new file 100644
 
EB:13:D0:9B:B1:4A:CB:FB:34:6E:03:8C:A3:34:C8:64:6A:E9:20:41
roles/kiosk/files/barrier/SSL/Fingerprints/TrustedServers.txt
Show inline comments
 
new file 100644
 
EB:13:D0:9B:B1:4A:CB:FB:34:6E:03:8C:A3:34:C8:64:6A:E9:20:41
roles/kiosk/files/barrierConfiguration
Show inline comments
 
new file 100644
 
section: screens
 
	mcr-alpha:
 
		halfDuplexCapsLock = false
 
		halfDuplexNumLock = false
 
		halfDuplexScrollLock = false
 
		xtestIsXineramaUnaware = false
 
		preserveFocus = false
 
		switchCorners = none 
 
		switchCornerSize = 0
 
	mcr-beta:
 
		halfDuplexCapsLock = false
 
		halfDuplexNumLock = false
 
		halfDuplexScrollLock = false
 
		xtestIsXineramaUnaware = false
 
		preserveFocus = false
 
		switchCorners = none 
 
		switchCornerSize = 0
 
	mcr-gamma:
 
		halfDuplexCapsLock = false
 
		halfDuplexNumLock = false
 
		halfDuplexScrollLock = false
 
		xtestIsXineramaUnaware = false
 
		preserveFocus = false
 
		switchCorners = none 
 
		switchCornerSize = 0
 
	mcr-delta:
 
		halfDuplexCapsLock = false
 
		halfDuplexNumLock = false
 
		halfDuplexScrollLock = false
 
		xtestIsXineramaUnaware = false
 
		preserveFocus = false
 
		switchCorners = none 
 
		switchCornerSize = 0
 
end
 

	
 
section: aliases
 
end
 

	
 
section: links
 
	mcr-alpha:
 
		right = mcr-beta
 
		down = mcr-gamma
 
	mcr-beta:
 
		left = mcr-alpha
 
		down = mcr-delta
 
	mcr-gamma:
 
		right = mcr-delta
 
		up = mcr-alpha
 
	mcr-delta:
 
		left = mcr-gamma
 
		up = mcr-beta
 
end
 

	
 
section: options
 
	relativeMouseMoves = false
 
	screenSaverSync = true
 
	win32KeepForeground = false
 
	clipboardSharing = true
 
	switchCorners = none 
 
	switchCornerSize = 0
 
end
roles/kiosk/tasks/barrier.yml
Show inline comments
 
new file 100644
 
# This task list sets up barrier
 
---
 
- name: Copy barrier config
 
  ansible.builtin.copy:
 
    dest: ~/barrierConfiguration
 
    src: barrierConfiguration
 
    mode: 0644
 

	
 
- name: Copy barrier SSL files
 
  ansible.builtin.copy:
 
    dest: ~/.local/share/barrier/SSL/Fingerprints/
 
    src: barrier/SSL/Fingerprints/
 
    mode: 0644
 
    directory_mode: 0755
 

	
 
- name: Make key read only to user
 
  ansible.builtin.copy:
 
    mode: '0600'
 
    src: barrier/SSL/Barrier.pem
 
    dest: '~/.local/share/barrier/SSL/Barrier.pem'
roles/kiosk/tasks/main.yml
Show inline comments
 
new file 100644
 
# This role sets up a kiosk
 
- name: Install software (browser, KVM)
 
  import_tasks: software.yml
 
- name: Setup barrier
 
  import_tasks: barrier.yml
 
- name: Setup window manager
 
  import_tasks: wm.yml
 
- name: Reboot
 
  become: yes
 
  become_user: root
 
  ansible.builtin.reboot:
 
    msg: "Rebooting kiosk after setup..."
roles/kiosk/tasks/software.yml
Show inline comments
 
new file 100644
 
# This task list sets up the basic tools
 
---
 
- name: Install browser
 
  become: yes
 
  community.general.pacman:
 
    name: firefox
 
    state: present
 
- name: Install Xorg & wm & tools
 
  become: yes
 
  community.general.pacman:
 
    name:
 
      - xorg-xinit
 
      - xorg-server
 
      - xorg-xset
 
      - xorg-setxkbmap
 
      - unclutter
 
      - openbox
 
      - xf86-video-odroid-c2
 
      - ttf-liberation
 
      - barrier-headless
 
    state: present
roles/kiosk/tasks/wm.yml
Show inline comments
 
new file 100644
 
# This task list sets up the window manager
 
---
 
- name: Create autologin directory
 
  become: yes
 
  become_user: root
 
  ansible.builtin.file:
 
    state: directory
 
    path: '/etc/systemd/system/getty@tty1.service.d/'
 
    mode: '0755'
 
    owner: root
 
    group: root
 

	
 
- name: Autologin
 
  become: yes
 
  become_user: root
 
  ansible.builtin.copy:
 
    src: agettyAutologin
 
    dest: '/etc/systemd/system/getty@tty1.service.d/override.conf'
 
    owner: root
 
    group: root
 
    mode: '0644'
 

	
 
- name: xinitrc
 
  ansible.builtin.copy:
 
    dest: ~/.xinitrc
 
    content: 'exec openbox-session'
 
    mode: 0644
 

	
 
- name: Create autologin directory
 
  ansible.builtin.file:
 
    state: directory
 
    path: '~/.config/openbox'
 
    mode: '0755'
 

	
 
- name: Setup openbox autostart
 
  ansible.builtin.template:
 
    src: openboxAutocomplete.j2
 
    dest: ~/.config/openbox/autostart
 
    mode: 0644
 

	
 
- name: Autostart X on tty1 on odroid
 
  ansible.builtin.lineinfile:
 
    path: '~/.bashrc'
 
    state: present
 
    line: '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && xinit'
 
    mode: 0644
roles/kiosk/templates/openboxAutocomplete.j2
Show inline comments
 
new file 100644
 
(sleep 1s && xset s off) &
 
(sleep 1s && xset s noblank) &
 
(sleep 1s && xset -dpms) &
 
(sleep 1s && setxkbmap -option terminate:ctrl_alt_bksp) &
 
(sleep 1s && unclutter) &
 
(sleep 1s && firefox --kiosk {{ dashboardUrl }}) &
 
(sleep 1s && {{ barrierCommand }})
 

	
roles/localKey/tasks/main.yml
Show inline comments
 
new file 100644
 
- name: Local SSH keypair and remote deployment
 
  delegate_to: localhost
 
  throttle: 1
 
  ansible.builtin.script:
 
    chdir: "{{ inventory_dir }}"
 
    cmd: init.sh "{{ ansible_host }}"
 
  register: cmd_reg
 
- debug: msg="{{ cmd_reg.stdout }}"
roles/python/tasks/3.yml
Show inline comments
 
new file 100644
 
- name: Pacman keyring + Python installation
 
  delegate_to: localhost
 
  ansible.builtin.shell: |
 
    expect <<EOD
 
    spawn sshpass -p alarm ssh \
 
      -o UserKnownHostsFile=/dev/null \
 
      -o StrictHostKeyChecking=no \
 
      -o PubkeyAuthentication=false \
 
      alarm@{{ inventory_hostname }} \
 
      "su -c \"touch SUDOTEST; touch SUDOTEST2; touch SUDOTEST3\""
 
    expect "Password: "
 
    send -- "root\r"
 
    interact
 
    EOD
 

	
 

	
 

	
 

	
 

	
 
#spawn sshpass -p alarm ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=false alarm@{{ inventory_hostname }} "su -c \"touch SUDOTEST\; touch SUDOTEST2\; touch SUDOTEST3\""
 
#spawn sshpass -p alarm ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=false alarm@{{ inventory_hostname }} "su -c \"pacman-key --init\; pacman-key --populate archlinuxarm\; pacman --noconfirm -S python\""
roles/python/tasks/main.yml
Show inline comments
 
new file 100644
 
# $DATE is host time, which we force set on the target machine.
 
# Allows downloading stuff without TLS errors
 
- name: Pacman keyring + Python installation
 
  delegate_to: localhost
 
  ansible.builtin.shell: |
 
    DATE=$(date "+%F %T")
 
    expect <<EOD
 
        set timeout 600
 
        spawn sshpass -p alarm ssh \
 
          -o UserKnownHostsFile=/dev/null \
 
          -o StrictHostKeyChecking=no \
 
          -o PubkeyAuthentication=false \
 
          alarm@{{ ansible_host }}
 
        expect "$ "
 
        send "su\r"
 
        expect "Password: "
 
        send "root\r"
 
        expect "alarm alarm]# "
 
        send -- "date --set=\"$DATE\"\; "
 
        send -- "pacman-key --init\; "
 
        send -- "pacman-key --populate archlinuxarm\; "
 
        send -- "pacman -q --noconfirm -Sy python\r"
 
        expect "alarm alarm]# "
 
        interact
 
    EOD
 
  register: cmd_reg
 
- debug: msg="{{ cmd_reg.stdout }}"
site.yml
Show inline comments
 
new file 100644
 
---
 
- name: Create local key and deploy it
 
  hosts: cnc
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - localKey
 

	
 
- name: Install python
 
  hosts: cnc
 
  remote_user: null
 
  gather_facts: false
 
  roles:
 
    - python
 

	
 
- name: Setup pi
 
  hosts: cnc
 
  remote_user: alarm
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - initial
 

	
 
- name: Setup kiosk
 
  hosts: cnc
 
  remote_user: odroid
 
  vars:
 
    ansible_host_key_checking: false
 
    ansible_ssh_host_key_checking: false
 
  roles:
 
    - kiosk
0 comments (0 inline, 0 general)