From 36c6dfa2e929196db7aaca5050973bbf700eee39 Mon Sep 17 00:00:00 2001 From: Jochen Demmer Date: Wed, 18 Jan 2023 19:17:25 +0100 Subject: [PATCH] finalizing uhttpd role for release 0.4.3 --- README.md | 3 +- galaxy.yml | 4 +- roles/ansible_openwrtuhttpd/README.md | 39 +------------------ roles/ansible_openwrtuhttpd/defaults/main.yml | 4 ++ roles/ansible_openwrtuhttpd/handlers/main.yml | 4 ++ roles/ansible_openwrtuhttpd/tasks/main.yml | 29 ++++++++++++++ 6 files changed, 42 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index fec106f..508a91a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ansible-galaxy collection install imp1sh.ansible_openwrt ``` This is an Ansible collection for OpenWrt devices. It will only work if you have enough flash space available to install python which is required. Details can be found in the [documentation](https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection). -It has been tested on virtualized x86 (kvm), PC Engines APU4, Edgerouter X and Deciso DEC740. +It has been tested on a considerate amount of different devices. ## Who is this for? OpenWrt typically is being used in small environments but this collection is a game changer. You could run virtualized firewalls with this in cloud environments or as a hosting provider. This role is an alternative solution to what OpenWisp does. You can manage hundreds or thousands of devices centrally with Ansible. @@ -27,6 +27,7 @@ Sections: - [Ansible OpenWrt Service](https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection/roleServices) - [Ansible OpenWrt System](https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection/roleSystem) - [Ansible OpenWrt Tinyproxy](https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection/roleTinyproxy) +- [Ansible OpenWrt uhttpd](https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection/roleUhttpd) - [Ansible OpenWrt Wireguard](https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection/roleWireguard) - [Ansible OpenWrt Wireless](https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection/roleWireless) - [Ansible OpenWrt Imagebuilder](https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection/roleImagebuilder) diff --git a/galaxy.yml b/galaxy.yml index 5cfb038..c9df67c 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,13 +1,13 @@ --- namespace: imp1sh name: ansible_openwrt -version: 0.4.0 +version: 0.4.3 readme: README.md authors: - Jochen Demmer description: ansible_openwrt is a full featured openwrt collection. It relies on python so you need enough disk space in order to be able to use it. license_file: 'LICENSE' -tags: [openwrt, lede, dhcp, dnsmasq, dropbear, ssh, firewall, network, packages, restic, backup, services, system, wifi, wireless, wireguard, vpn, sqm, imagebuilder, wireguard] +tags: [openwrt, lede, dhcp, dnsmasq, dropbear, ssh, firewall, network, packages, restic, backup, services, system, wifi, wireless, wireguard, vpn, sqm, imagebuilder, wireguard, uhttpd, tinyproxy, imagebuilder] dependencies: {} repository: https://github.com/imp1sh/ansible_openwrt documentation: https://wiki.junicast.de/en/junicast/docs/AnsibleOpenWrtCollection diff --git a/roles/ansible_openwrtuhttpd/README.md b/roles/ansible_openwrtuhttpd/README.md index 225dd44..a77a7a6 100644 --- a/roles/ansible_openwrtuhttpd/README.md +++ b/roles/ansible_openwrtuhttpd/README.md @@ -1,38 +1 @@ -Role Name -========= - -A brief description of the role goes here. - -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. - -Role Variables --------------- - -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. - -Dependencies ------------- - -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - { role: username.rolename, x: 42 } - -License -------- - -BSD - -Author Information ------------------- - -An optional section for the role authors to include contact information, or a website (HTML is not allowed). +https://github.com/imp1sh/ansible_openwrt diff --git a/roles/ansible_openwrtuhttpd/defaults/main.yml b/roles/ansible_openwrtuhttpd/defaults/main.yml index 863d32d..4f0e0c8 100644 --- a/roles/ansible_openwrtuhttpd/defaults/main.yml +++ b/roles/ansible_openwrtuhttpd/defaults/main.yml @@ -1,4 +1,8 @@ --- +openwrt_uhttpd_deployroot: "/" +openwrt_uhttpd_deploypath: "{{ openwrt_uhttpd_deployroot }}etc/config" +openwrt_uhttpd_deployfile: "uhttpd" +openwrt_uhttpd_cert_searchpath: "/etc/acme/{{ inventory_hostname }}" openwrt_uhttpd_main_listen_http: - "0.0.0.0:80" - "[::]:80" diff --git a/roles/ansible_openwrtuhttpd/handlers/main.yml b/roles/ansible_openwrtuhttpd/handlers/main.yml index f7f3082..4ac436a 100644 --- a/roles/ansible_openwrtuhttpd/handlers/main.yml +++ b/roles/ansible_openwrtuhttpd/handlers/main.yml @@ -1,2 +1,6 @@ --- # handlers file for ansible_uhttpd +- name: restart uhttpd + ansible.builtin.service: + name: uhttpd + state: restarted diff --git a/roles/ansible_openwrtuhttpd/tasks/main.yml b/roles/ansible_openwrtuhttpd/tasks/main.yml index a767274..a22e742 100644 --- a/roles/ansible_openwrtuhttpd/tasks/main.yml +++ b/roles/ansible_openwrtuhttpd/tasks/main.yml @@ -1,2 +1,31 @@ --- # tasks file for ansible_uhttpd +- name: Make sure deploypath is present + ansible.builtin.file: + path: "{{ openwrt_uhttpd_deploypath }}" + state: directory +- name: search for existing certificate + ansible.builtin.stat: + path: "{{ openwrt_uhttpd_cert_searchpath }}/{{ inventory_hostname }}.cer" + register: searchcert +- name: search for existing key + ansible.builtin.stat: + path: "{{ openwrt_uhttpd_cert_searchpath }}/{{ inventory_hostname }}.key" + register: searchkey +- name: debug + debug: + msg: "{{ searchcert }}" +- name: overwrite defaults with found cert and key + ansible.builtin.set_fact: + openwrt_uhttpd_main_cert: "{{ searchcert.stat.path }}" + openwrt_uhttpd_main_key: "{{ searchkey.stat.path }}" + when: + - searchkey is defined + - searchcert is defined + - searchkey.stat.exists + - searchcert.stat.exists +- name: Deploy uhttpd config + ansible.builtin.template: + src: "uhttpd.jinja2" + dest: "{{ openwrt_uhttpd_deploypath }}/{{ openwrt_uhttpd_deployfile }}" + notify: restart uhttpd