From 60134dba951f62f340d50ce4d6e76d04721c113c Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Mon, 21 Aug 2023 20:26:45 -0300 Subject: [PATCH] Add OpenBSD --- main.yml | 3 +++ roles/openbsd/tasks/main.yml | 23 +++++++++++++++++++ roles/openbsd/tasks/packages-cli.yml | 25 ++++++++++++++++++++ roles/openbsd/tasks/packages-gui.yml | 28 +++++++++++++++++++++++ roles/openbsd/tasks/qemu-guest.yml | 22 ++++++++++++++++++ roles/openbsd/tasks/rc.yml | 28 +++++++++++++++++++++++ roles/openbsd/tasks/ssh.yml | 34 ++++++++++++++++++++++++++++ 7 files changed, 163 insertions(+) create mode 100644 roles/openbsd/tasks/main.yml create mode 100644 roles/openbsd/tasks/packages-cli.yml create mode 100644 roles/openbsd/tasks/packages-gui.yml create mode 100644 roles/openbsd/tasks/qemu-guest.yml create mode 100644 roles/openbsd/tasks/rc.yml create mode 100644 roles/openbsd/tasks/ssh.yml diff --git a/main.yml b/main.yml index 3be5d68..b947b1d 100755 --- a/main.yml +++ b/main.yml @@ -58,6 +58,9 @@ - include_role: name: netbsd when: ansible_distribution == 'NetBSD' +- include_role: + name: openbsd + when: ansible_distribution == 'OpenBSD' - include_role: name: ubuntu when: ansible_distribution == 'Ubuntu' diff --git a/roles/openbsd/tasks/main.yml b/roles/openbsd/tasks/main.yml new file mode 100644 index 0000000..8142252 --- /dev/null +++ b/roles/openbsd/tasks/main.yml @@ -0,0 +1,23 @@ +--- +# Copyright 2021-2023 Anthony Perkins +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- import_tasks: packages-cli.yml +- import_tasks: packages-gui.yml + when: gui == true +- import_tasks: rc.yml +- import_tasks: ssh.yml +- import_tasks: qemu-guest.yml + when: gui == true and ansible_virtualization_role == "guest" and ansible_virtualization_type == "kvm" + diff --git a/roles/openbsd/tasks/packages-cli.yml b/roles/openbsd/tasks/packages-cli.yml new file mode 100644 index 0000000..b1ab546 --- /dev/null +++ b/roles/openbsd/tasks/packages-cli.yml @@ -0,0 +1,25 @@ +--- +# Copyright 2021-2023 Anthony Perkins +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Install core CLI packages + become: true + community.general.openbsd_pkg: + name: '{{ packages }}' + state: present + vars: + packages: + - ansible + - git + - mc diff --git a/roles/openbsd/tasks/packages-gui.yml b/roles/openbsd/tasks/packages-gui.yml new file mode 100644 index 0000000..8bd53f8 --- /dev/null +++ b/roles/openbsd/tasks/packages-gui.yml @@ -0,0 +1,28 @@ +--- +# Copyright 2021-2023 Anthony Perkins +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Install core GUI packages + become: true + community.general.openbsd_pkg: + name: '{{ packages }}' + state: present + vars: + packages: + - firefox + - icewm + - keepassxc + - noto-fonts + - rxvt-unicode + - vim--no_x11 diff --git a/roles/openbsd/tasks/qemu-guest.yml b/roles/openbsd/tasks/qemu-guest.yml new file mode 100644 index 0000000..44b41b8 --- /dev/null +++ b/roles/openbsd/tasks/qemu-guest.yml @@ -0,0 +1,22 @@ +--- +# Copyright 2021-2023 Anthony Perkins +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Set QEMU UEFI screen resolution + become: true + ansible.builtin.lineinfile: + path: /etc/boot.conf + regexp: '^machine gop .*' + line: 'machine gop 6' + create: yes diff --git a/roles/openbsd/tasks/rc.yml b/roles/openbsd/tasks/rc.yml new file mode 100644 index 0000000..bec140b --- /dev/null +++ b/roles/openbsd/tasks/rc.yml @@ -0,0 +1,28 @@ +--- +# Copyright 2021-2023 Anthony Perkins +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Enable XDM + become: true + ansible.builtin.lineinfile: + path: /etc/rc.conf.local + regexp: '^xenodm_flags=.*' + line: 'xenodm_flags=' + create: yes +- name: Enable dbus + become: true + ansible.builtin.lineinfile: + path: /etc/rc.conf.local + regexp: '^messagebus_flags=.*' + line: 'messagebus_flags=' diff --git a/roles/openbsd/tasks/ssh.yml b/roles/openbsd/tasks/ssh.yml new file mode 100644 index 0000000..585fdcc --- /dev/null +++ b/roles/openbsd/tasks/ssh.yml @@ -0,0 +1,34 @@ +--- +# Copyright 2021-2023 Anthony Perkins +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Disable SSH passwords + become: true + ansible.builtin.lineinfile: + path: /etc/ssh/sshd_config + regexp: '^#?\w*PasswordAuthentication (yes|no)' + line: 'PasswordAuthentication no' + register: changed_ssh_config +- name: Enable SSH + become: true + ansible.builtin.service: + name: sshd + enabled: yes + state: started +- name: Restart SSH + become: true + ansible.builtin.service: + name: sshd + state: restarted + when: changed_ssh_config.changed == true