diff --git a/defaults/main.yml b/defaults/main.yml index 0b3852e..5c6b761 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,4 +31,5 @@ deploy_haproxy_frontend: - default_backend default deploy_haproxy_backend: [] + deploy_haproxy_listen: [] diff --git a/molecule/default/requirements.yml b/molecule/default/requirements.yml new file mode 100644 index 0000000..0a4a9fb --- /dev/null +++ b/molecule/default/requirements.yml @@ -0,0 +1,5 @@ +--- +# requirements file for molecule +roles: + - name: ednxzu.manage_repositories + - name: ednxzu.manage_apt_packages diff --git a/tasks/install_host.yml b/tasks/install_host.yml new file mode 100644 index 0000000..75ecc36 --- /dev/null +++ b/tasks/install_host.yml @@ -0,0 +1,9 @@ +--- +# task/install_host file for deploy_haproxy +- name: "Configure haproxy repository" + ansible.builtin.include_role: + name: ednxzu.manage_repositories + vars: + manage_repositories_enable_default_repo: false + manage_repositories_enable_custom_repo: true + manage_repositories_custom_repo: "{{ deploy_haproxy_repository[ansible_distribution|lower] }}" diff --git a/tasks/main.yml b/tasks/main.yml index a768eea..7a8fd33 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,7 @@ --- # task/main file for deploy_haproxy +- name: "Import prerequisites.yml" + ansible.builtin.include_tasks: prerequisites.yml + +- name: "Import install_host.yml" + ansible.builtin.include_tasks: install_host.yml diff --git a/tasks/prerequisites.yml b/tasks/prerequisites.yml index e9fbb8a..7fc6a41 100644 --- a/tasks/prerequisites.yml +++ b/tasks/prerequisites.yml @@ -1,2 +1,53 @@ --- # task/prerequisites file for deploy_haproxy +- name: "Prerequisites for host installation" + when: deploy_haproxy_deploy_method == 'host' + block: + - name: "Create group {{ deploy_haproxy_group }}" + ansible.builtin.group: + name: "{{ deploy_haproxy_group }}" + state: present + + - name: "Create user {{ deploy_haproxy_user }}" + ansible.builtin.user: + name: "{{ deploy_haproxy_user }}" + group: "{{ deploy_haproxy_group }}" + home: "{{ deploy_haproxy_chroot }}" + create_home: false + shell: /bin/false + state: present + + - name: "Create directory {{ deploy_haproxy_config_dir }}" + ansible.builtin.file: + path: "{{ deploy_haproxy_config_dir }}" + state: directory + owner: "{{ deploy_haproxy_user }}" + group: "{{ deploy_haproxy_group }}" + mode: "0755" + + - name: "Create directory {{ deploy_haproxy_chroot }}" + ansible.builtin.file: + path: "{{ deploy_haproxy_chroot }}" + state: directory + owner: "{{ deploy_haproxy_user }}" + group: "{{ deploy_haproxy_group }}" + mode: "0755" + +- name: "Prerequisites for docker installation" + when: deploy_haproxy_deploy_method == 'docker' + block: + - name: "Create directory {{ deploy_haproxy_config_dir }}" + ansible.builtin.file: + path: "{{ deploy_haproxy_config_dir }}" + state: directory + owner: "{{ deploy_haproxy_user }}" + group: "{{ deploy_haproxy_group }}" + mode: "0755" + + - name: "Create directory {{ deploy_haproxy_chroot}}" + ansible.builtin.file: + path: "{{ deploy_haproxy_chroot }}" + state: directory + owner: "{{ deploy_haproxy_user }}" + group: "{{ deploy_haproxy_group }}" + mode: "0755" diff --git a/vars/main.yml b/vars/main.yml index aa6a1a6..b9ba8d3 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,35 @@ --- # vars file for deploy_haproxy +deploy_haproxy_config_dir: /etc/haproxy +deploy_haproxy_socket: /var/lib/haproxy/stats +deploy_haproxy_chroot: /var/lib/haproxy +deploy_haproxy_user: haproxy +deploy_haproxy_group: haproxy +deploy_haproxy_version_map: + latest: "2.9" + +deploy_haproxy_repository: + debian: + - name: haproxy + uri: "http://haproxy.debian.net" + comments: "haproxy repository" + types: + - deb + suites: + - "{{ ansible_distribution_release }}-backports-{{ deploy_haproxy_version_map[deploy_haproxy_version] | default(deploy_haproxy_version) }}" + components: + - main + options: + Signed-By: "https://haproxy.debian.net/bernat.debian.org.gpg" + ubuntu: + - name: haproxy + uri: "https://ppa.launchpadcontent.net/vbernat/haproxy-{{ deploy_haproxy_version_map[deploy_haproxy_version] | default(deploy_haproxy_version) }}/ubuntu/" + comments: "haproxy repository" + types: + - deb + suites: + - "{{ ansible_distribution_release }}" + components: + - main + options: + Signed-By: "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xcffb779aadc995e4f350a060505d97a41c61b9cd"