From 7de6bc92310739de8077f5041aee3c8fb623021d Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 10 Dec 2022 15:29:19 -0500 Subject: [PATCH] Add a role for portshaker. --- .../environments/laptop/host_vars/odofreebsd | 4 ++ ansible/playbook.yaml | 1 + ansible/roles/hosts/tasks/common.yaml | 2 +- ansible/roles/portshaker/files/freebsd | 10 ++++ ansible/roles/portshaker/files/myrepo | 10 ++++ .../roles/portshaker/files/portshaker.conf | 8 +++ ansible/roles/portshaker/tasks/common.yaml | 15 ++++++ ansible/roles/portshaker/tasks/freebsd.yaml | 50 +++++++++++++++++++ ansible/roles/portshaker/tasks/linux.yaml | 21 ++++++++ ansible/roles/portshaker/tasks/main.yaml | 2 + ansible/roles/portshaker/tasks/peruser.yaml | 29 +++++++++++ .../portshaker/tasks/peruser_freebsd.yaml | 0 .../roles/portshaker/tasks/peruser_linux.yaml | 0 .../roles/sway/files/launch_sway_freebsd.bash | 2 + .../roles/sway/files/launch_sway_linux.bash | 2 + 15 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 ansible/roles/portshaker/files/freebsd create mode 100644 ansible/roles/portshaker/files/myrepo create mode 100644 ansible/roles/portshaker/files/portshaker.conf create mode 100644 ansible/roles/portshaker/tasks/common.yaml create mode 100644 ansible/roles/portshaker/tasks/freebsd.yaml create mode 100644 ansible/roles/portshaker/tasks/linux.yaml create mode 100644 ansible/roles/portshaker/tasks/main.yaml create mode 100644 ansible/roles/portshaker/tasks/peruser.yaml create mode 100644 ansible/roles/portshaker/tasks/peruser_freebsd.yaml create mode 100644 ansible/roles/portshaker/tasks/peruser_linux.yaml diff --git a/ansible/environments/laptop/host_vars/odofreebsd b/ansible/environments/laptop/host_vars/odofreebsd index 2e2ac18..e74ec32 100644 --- a/ansible/environments/laptop/host_vars/odofreebsd +++ b/ansible/environments/laptop/host_vars/odofreebsd @@ -53,3 +53,7 @@ sway_conf_files: wireguard_directory: odo enabled_wireguard: - wgh +poudriere_builds: + - jail: current + ports: default + set: framework diff --git a/ansible/playbook.yaml b/ansible/playbook.yaml index 26470e7..d19ced0 100644 --- a/ansible/playbook.yaml +++ b/ansible/playbook.yaml @@ -36,6 +36,7 @@ - google_cloud_sdk - ansible - wireguard + - portshaker - hosts: nat_dhcp:homeserver_nat_dhcp vars: diff --git a/ansible/roles/hosts/tasks/common.yaml b/ansible/roles/hosts/tasks/common.yaml index 32cb8ba..654e56f 100644 --- a/ansible/roles/hosts/tasks/common.yaml +++ b/ansible/roles/hosts/tasks/common.yaml @@ -1,7 +1,7 @@ - name: Set the /etc/hosts ansible.builtin.lineinfile: path: /etc/hosts - regexp: '^{{ item.key | regex_escape() }}' + regexp: '^{{ item.key | regex_escape() }}\s+' line: "{{ item.key }} {{ item.value | join(' ') }}" loop: "{{ etc_hosts | dict2items }}" diff --git a/ansible/roles/portshaker/files/freebsd b/ansible/roles/portshaker/files/freebsd new file mode 100644 index 0000000..78bbe59 --- /dev/null +++ b/ansible/roles/portshaker/files/freebsd @@ -0,0 +1,10 @@ +#!/bin/sh +. /usr/local/share/portshaker/portshaker.subr +if [ "$1" != '--' ]; then + err 1 "Extra arguments" +fi +shift +method="git" +git_clone_uri="https://github.com/freebsd/freebsd-ports.git" +git_branch="main" +run_portshaker_command $* diff --git a/ansible/roles/portshaker/files/myrepo b/ansible/roles/portshaker/files/myrepo new file mode 100644 index 0000000..cbfb281 --- /dev/null +++ b/ansible/roles/portshaker/files/myrepo @@ -0,0 +1,10 @@ +#!/bin/sh +. /usr/local/share/portshaker/portshaker.subr +if [ "$1" != '--' ]; then + err 1 "Extra arguments" +fi +shift +method="git" +git_clone_uri="https://code.fizz.buzz/talexander/ta_ports.git" +git_branch="master" +run_portshaker_command $* diff --git a/ansible/roles/portshaker/files/portshaker.conf b/ansible/roles/portshaker/files/portshaker.conf new file mode 100644 index 0000000..0f92d26 --- /dev/null +++ b/ansible/roles/portshaker/files/portshaker.conf @@ -0,0 +1,8 @@ +#---[ Base directory for mirrored Ports Trees ]--- +mirror_base_dir="/var/cache/portshaker" + +#---[ Directories where to merge ports ]--- +ports_trees="main" + +main_ports_tree="/usr/local/portshaker/trees/main" +main_merge_from="freebsd myrepo" diff --git a/ansible/roles/portshaker/tasks/common.yaml b/ansible/roles/portshaker/tasks/common.yaml new file mode 100644 index 0000000..fef1101 --- /dev/null +++ b/ansible/roles/portshaker/tasks/common.yaml @@ -0,0 +1,15 @@ +- import_tasks: tasks/freebsd.yaml + when: 'os_flavor == "freebsd"' + +- import_tasks: tasks/linux.yaml + when: 'os_flavor == "linux"' + +- include_tasks: + file: tasks/peruser.yaml + apply: + become: yes + become_user: "{{ initialize_user }}" + when: users is defined + loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}" + loop_control: + loop_var: initialize_user diff --git a/ansible/roles/portshaker/tasks/freebsd.yaml b/ansible/roles/portshaker/tasks/freebsd.yaml new file mode 100644 index 0000000..1cb2abc --- /dev/null +++ b/ansible/roles/portshaker/tasks/freebsd.yaml @@ -0,0 +1,50 @@ +# Update ports tree: +# portshaker -U +# portshaker -M +# +# Force build: +# poudriere bulk -J 4 -C -j current -p default -z testing sysutils/kubectx +# +# Test build with interactive shell +# poudriere testport -i -J 4 -j current -p default -z testing sysutils/kubectx +# optional add -w to save the work directory + +- name: Install packages + package: + name: + - portshaker + state: present + +- name: Create directories + file: + name: "{{ item }}" + state: directory + mode: 0755 + owner: root + group: wheel + loop: + - /usr/local/portshaker/trees + +- name: Install Configuration + copy: + src: "files/{{ item.src }}" + dest: "{{ item.dest }}" + mode: 0644 + owner: root + group: wheel + loop: + - src: portshaker.conf + dest: /usr/local/etc/portshaker.conf + +- name: Install Scripts + copy: + src: "files/{{ item.src }}" + dest: "{{ item.dest }}" + mode: 0755 + owner: root + group: wheel + loop: + - src: freebsd + dest: /usr/local/etc/portshaker.d/freebsd + - src: myrepo + dest: /usr/local/etc/portshaker.d/myrepo diff --git a/ansible/roles/portshaker/tasks/linux.yaml b/ansible/roles/portshaker/tasks/linux.yaml new file mode 100644 index 0000000..429ad91 --- /dev/null +++ b/ansible/roles/portshaker/tasks/linux.yaml @@ -0,0 +1,21 @@ +# - name: Build aur packages +# register: buildaur +# become_user: "{{ build_user.name }}" +# command: "aurutils-sync --no-view {{ item }}" +# args: +# creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*" +# loop: +# - foo + +# - name: Update cache +# when: buildaur.changed +# pacman: +# name: [] +# state: present +# update_cache: true + +# - name: Install packages +# package: +# name: +# - foo +# state: present diff --git a/ansible/roles/portshaker/tasks/main.yaml b/ansible/roles/portshaker/tasks/main.yaml new file mode 100644 index 0000000..87fe19a --- /dev/null +++ b/ansible/roles/portshaker/tasks/main.yaml @@ -0,0 +1,2 @@ +- import_tasks: tasks/common.yaml + when: poudriere_builds is defined and poudriere_builds diff --git a/ansible/roles/portshaker/tasks/peruser.yaml b/ansible/roles/portshaker/tasks/peruser.yaml new file mode 100644 index 0000000..111e886 --- /dev/null +++ b/ansible/roles/portshaker/tasks/peruser.yaml @@ -0,0 +1,29 @@ +- include_role: + name: per_user + +# - name: Create directories +# file: +# name: "{{ account_homedir.stdout }}/{{ item }}" +# state: directory +# mode: 0700 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}" +# loop: +# - ".config/foo" + +# - name: Copy files +# copy: +# src: "files/{{ item.src }}" +# dest: "{{ account_homedir.stdout }}/{{ item.dest }}" +# mode: 0600 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}" +# loop: +# - src: foo.conf +# dest: .config/foo/foo.conf + +- import_tasks: tasks/peruser_freebsd.yaml + when: 'os_flavor == "freebsd"' + +- import_tasks: tasks/peruser_linux.yaml + when: 'os_flavor == "linux"' diff --git a/ansible/roles/portshaker/tasks/peruser_freebsd.yaml b/ansible/roles/portshaker/tasks/peruser_freebsd.yaml new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/portshaker/tasks/peruser_linux.yaml b/ansible/roles/portshaker/tasks/peruser_linux.yaml new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/sway/files/launch_sway_freebsd.bash b/ansible/roles/sway/files/launch_sway_freebsd.bash index ba743c0..dfb1225 100644 --- a/ansible/roles/sway/files/launch_sway_freebsd.bash +++ b/ansible/roles/sway/files/launch_sway_freebsd.bash @@ -11,6 +11,8 @@ if [[ ! -v XDG_RUNTIME_DIR ]]; then fi +export XDG_CURRENT_DESKTOP=sway + # Enable wayland support for firefox export MOZ_ENABLE_WAYLAND=1 diff --git a/ansible/roles/sway/files/launch_sway_linux.bash b/ansible/roles/sway/files/launch_sway_linux.bash index f7d9561..d1e10a3 100644 --- a/ansible/roles/sway/files/launch_sway_linux.bash +++ b/ansible/roles/sway/files/launch_sway_linux.bash @@ -5,4 +5,6 @@ set -euo pipefail IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +export XDG_CURRENT_DESKTOP=sway + exec sway -d &> $HOME/.config/swaylog