diff --git a/abyayala.yml b/abyayala.yml index 5332306..816f01b 100644 --- a/abyayala.yml +++ b/abyayala.yml @@ -232,4 +232,4 @@ matrix: domains: - llavero.abyaya.la nodo: llavero.comun - force_https: yes + force_https: yes \ No newline at end of file diff --git a/group_vars/testing/vars b/group_vars/testing/vars new file mode 100644 index 0000000..d43597d --- /dev/null +++ b/group_vars/testing/vars @@ -0,0 +1 @@ +host_ip: 157.180.114.62 diff --git a/hosts.production b/hosts.production index 7af3cda..8013b4f 100644 --- a/hosts.production +++ b/hosts.production @@ -1,5 +1,5 @@ [localhost] -127.0.0.1 +127.0.0.1 ansible_connection=local [hetzner] 5.161.236.18 @@ -11,3 +11,9 @@ ansible_ssh_user=root sutty.nl [sutty:vars] + +[testing] +157.180.114.62 + +[testing:vars] +ansible_ssh_user=root diff --git a/roles/althost/tasks/compose.yml b/roles/althost/tasks/compose.yml index b69e8d0..6f4140a 100644 --- a/roles/althost/tasks/compose.yml +++ b/roles/althost/tasks/compose.yml @@ -1,13 +1,13 @@ - name: check if service volumes exists - local_action: - module: stat + stat: path: "{{ playbook_dir }}/roles/{{ item.roles[0] | default('proxy') }}/templates/volumes.yml" + delegate_to: localhost register: volumes_def - name: check if service networks exists - local_action: - module: stat + stat: path: "{{ playbook_dir }}/roles/{{ item.roles[0] | default('proxy') }}/templates/networks.yml" + delegate_to: localhost register: networks_def - set_fact: @@ -22,53 +22,53 @@ when: networks_def.stat.exists - name: define services in local composition - local_action: - module: blockinfile + blockinfile: path: "{{ local_compose_path }}/docker-compose.yml" insertafter: "services:" marker: "# {mark} {{ service_name|upper }}" block: "{{ services_content }}" + delegate_to: localhost changed_when: false - name: define volumes in local composition - local_action: - module: lineinfile + lineinfile: path: "{{ local_compose_path }}/docker-compose.yml" insertafter: "# volumenes compartidos" line: "volumes: #" state: present regexp: "volumes: #" + delegate_to: localhost when: volumes_def.stat.exists changed_when: false - name: define volumes content in local composition - local_action: - module: lineinfile + lineinfile: path: "{{ local_compose_path }}/docker-compose.yml" insertafter: "volumes: #" line: "{{ volumes_content }}" state: present regexp: "{{ volumes_content }}" + delegate_to: localhost when: volumes_content is defined changed_when: false - name: define networks in local composition - local_action: - module: lineinfile + lineinfile: path: "{{ local_compose_path }}/docker-compose.yml" insertafter: "# redes compartidas" line: "networks: #" state: present regexp: "networks: #" + delegate_to: localhost when: networks_def.stat.exists changed_when: false - name: define networks content in local composition - local_action: - module: lineinfile + lineinfile: path: "{{ local_compose_path }}/docker-compose.yml" insertafter: "networks: #" line: "{{ networks_content }}" state: present + delegate_to: localhost when: networks_content is defined changed_when: false diff --git a/roles/althost/tasks/main.yml b/roles/althost/tasks/main.yml index 163e3df..a01a0e5 100644 --- a/roles/althost/tasks/main.yml +++ b/roles/althost/tasks/main.yml @@ -1,28 +1,46 @@ # DOCKER CE this is specific for Debian # https://docs.docker.com/install/linux/docker-ce/debian/ + # Soporta Debian 12 (bookworm) y Debian 13 (trixie) - block: - name: "unattended upgrades" apt: name: "unattended-upgrades" state: "present" - + - name: required packages apt: - name: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg2', 'software-properties-common', 'python3-pip'] + name: ['ca-certificates', 'curl', 'python3-pip'] state: present - - name: docker signing key - apt_key: + - name: create keyrings directory + file: + path: /etc/apt/keyrings + state: directory + mode: '0755' + + - name: download docker gpg key + get_url: url: https://download.docker.com/linux/debian/gpg - state: present - - - name: docker apt repository - apt_repository: - repo: deb [arch=amd64] https://download.docker.com/linux/debian bookworm stable + dest: /etc/apt/keyrings/docker.asc + mode: '0644' - - name: install docker community edition + - name: add docker repository with deb822 format + deb822_repository: + name: docker + types: [deb] + uris: https://download.docker.com/linux/debian + suites: ["{{ ansible_distribution_release }}"] + components: [stable] + architectures: [amd64] + signed_by: /etc/apt/keyrings/docker.asc + + - name: install docker community edition and compose plugin apt: - name: docker-ce + name: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-compose-plugin update_cache: yes - name: is node already in swarm mode @@ -48,23 +66,11 @@ state: present # ansible-docker requirements - - name: python package docker-py is deprecated - pip: - name: docker-py - state: absent - break_system_packages: true - - - name: ensure python package docker is present - pip: - name: docker + # Use system packages instead of pip to avoid break_system_packages + - name: ensure python3-docker package is present + apt: + name: python3-docker state: present - break_system_packages: true - - - name: ensure python package docker-compose is present - pip: - name: docker-compose - state: present - break_system_packages: true tags: installation @@ -74,16 +80,16 @@ file: path={{ compose_path }} state=directory - name: make sure local compose path exists - local_action: - module: file - path: "{{ local_compose_path }}" + file: + path: "{{ local_compose_path }}" state: directory + delegate_to: localhost - name: clean docker-compose.yml - local_action: - module: template + template: dest: "{{ local_compose_path }}/docker-compose.yml" src: roles/althost/templates/docker-compose.yml + delegate_to: localhost changed_when: false - name: execute roles per domain mapping diff --git a/testnet.yml b/testnet.yml new file mode 100644 index 0000000..f9c621b --- /dev/null +++ b/testnet.yml @@ -0,0 +1,23 @@ +althost: testnet +matrix: + - service_name: comun + roles: + - kemal + domains: + - comun.abyayala.red + + - service_name: dns + roles: + - knsupdate + + - service_name: vpn + roles: + - rap + nodos: + - qi + + - service_name: qi + domains: + - qi.abyayala.red + nodo: qi.comun +# force_https: yes \ No newline at end of file