diff --git a/Vagrantfile b/Vagrantfile index 5e3d836..5b68c79 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -23,22 +23,30 @@ boxes = [ :box => "bento/ubuntu-18.04", :ip => '10.0.0.14', :cpu => "50", - :ram => "256" + :ram => "512" }, { :name => "debian-8", :box => "bento/debian-8", - :ip => '10.0.0.16', + :ip => '10.0.0.15', :cpu => "50", - :ram => "256" + :ram => "512" }, { :name => "debian-9", :box => "bento/debian-9", - :ip => '10.0.0.17', + :ip => '10.0.0.16', :cpu => "50", - :ram => "256" + :ram => "512" }, + { + :name => "centos-7", + :box => "centos/7", + :ip => '10.0.0.18', + :cpu => "80", + :ram => "1024" + } + ] Vagrant.configure("2") do |config| diff --git a/defaults/main.yml b/defaults/main.yml index 902ef68..2506f53 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,6 +2,11 @@ --- tinyproxy_install: [] +proxy_user: tinyproxy +proxy_group: tinyproxy + +tinyproxy_configuration_file: /etc/tinyproxy/tinyproxy.conf + tinyproxy_tinyproxy_conf: "{{ tinyproxy_tinyproxy_conf_preset }}" tinyproxy_port: 8888 @@ -10,3 +15,30 @@ tinyproxy_allow: tinyproxy_connect_port: - 443 - 563 + +tinyproxy_dependencies: + - tinyproxy + +tinyproxy_tinyproxy_conf_preset: + - | + User {{ proxy_user }} + Group {{ proxy_group }} + Port {{ tinyproxy_port }} + Timeout 600 + DefaultErrorFile "/usr/share/tinyproxy/default.html" + StatFile "/usr/share/tinyproxy/stats.html" + Logfile "/var/log/tinyproxy/tinyproxy.log" + LogLevel Info + PidFile "{{ pidfile | default("/run/tinyproxy/tinyproxy.pid") }}" + MaxClients 100 + MinSpareServers 5 + MaxSpareServers 20 + StartServers 10 + MaxRequestsPerChild 0 + {% for allow in tinyproxy_allow %} + Allow {{ allow }} + {% endfor %} + ViaProxyName "tinyproxy" + {% for connect_port in tinyproxy_connect_port %} + ConnectPort {{ connect_port }} + {% endfor %} diff --git a/tasks/Debian.yml b/tasks/Debian.yml new file mode 100644 index 0000000..e1b9d98 --- /dev/null +++ b/tasks/Debian.yml @@ -0,0 +1,45 @@ +--- + +# Tasks for Ubuntu + +- name: Set facts for Ubuntu 16 and Debian 8 + set_fact: + tinyproxy_configuration_file: /etc/tinyproxy.conf + proxy_user: nobody + proxy_group: nogroup + when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "14") or + (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "16") or + (ansible_distribution == "Debian" and ansible_distribution_major_version == "8") + +- name: Set facts for Ubuntu 18 and Debian 9 + set_fact: + tinyproxy_configuration_file: /etc/tinyproxy/tinyproxy.conf + proxy_user: tinyproxy + proxy_group: tinyproxy + pidfile: /var/run/tinyproxy/tinyproxy.pid + when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "18") or + (ansible_distribution == "Debian" and ansible_distribution_major_version == "9") + + +- name: Debian | Install the latest version of Tinyproxy + package: + name: "{{ tinyproxy_dependencies }}" + state: "{{ package_install_state | default('latest') }}" + when: + - ansible_os_family == 'Debian' + tags: + - configuration + - tinyproxy + - tinyproxy-dependencies + +- name: install additional + apt: + name: "{{ tinyproxy_install }}" + state: "{{ package_install_state | default('latest') }}" + when: + - ansible_os_family == 'Debian' + tags: + - configuration + - tinyproxy + - tinyproxy-install + diff --git a/tasks/RedHat.yml b/tasks/RedHat.yml new file mode 100644 index 0000000..00753ce --- /dev/null +++ b/tasks/RedHat.yml @@ -0,0 +1,31 @@ +--- + +- name: Set fact for CentOS 7 + set_fact: + gpgkey: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 + when: + - ansible_distribution == "CentOS" + - ansible_distribution_major_version == "7" + +- name: Set fact for CentOS 8 + set_fact: + gpgkey: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8 + when: + - ansible_distribution == "CentOS" + - ansible_distribution_major_version == "8" + +- name: RedHat | Install epel-release + yum_repository: + name: epel + description: EPEL YUM repo + baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$basearch/ + gpgkey: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 + when: + - ansible_os_family == 'RedHat' + +- name: RedHat | Install the latest version of Tinyproxy + yum: + name: "{{ tinyproxy_dependencies }}" + state: "{{ package_install_state | default('latest') }}" + when: + - ansible_os_family == 'RedHat' diff --git a/tasks/main.yml b/tasks/main.yml index 63ba921..af423b8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,35 +1,25 @@ # tasks file for tinyproxy --- -- name: include variables - include_vars: "{{ item }}" - with_first_found: - - "_{{ ansible_distribution_release }}.yml" - - "_{{ ansible_distribution | lower }}.yml" - - _default.yml - tags: - - configuration - - tinyproxy - - tinyproxy-include-variables -- name: install dependencies - apt: - name: "{{ tinyproxy_dependencies }}" - state: "{{ apt_install_state | default('latest') }}" - update_cache: true - cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" +- debug: + msg: "{{ hostvars[inventory_hostname].ansible_distribution }}" tags: - - configuration - - tinyproxy - - tinyproxy-dependencies - -- name: install additional - apt: - name: "{{ tinyproxy_install }}" - state: "{{ apt_install_state | default('latest') }}" + - debug + - never +- debug: + msg: "{{ hostvars[inventory_hostname].ansible_distribution_major_version }}" tags: - - configuration - - tinyproxy - - tinyproxy-install + - debug + - never +- debug: + msg: "{{ hostvars[inventory_hostname].ansible_distribution_version }}" + tags: + - debug + - never + +- name: include OS specific tasks + include_tasks: "{{ ansible_os_family }}.yml" + - name: update configuration file template: diff --git a/tests/post.yml b/tests/post.yml index 063ff90..a2c64bf 100644 --- a/tests/post.yml +++ b/tests/post.yml @@ -4,9 +4,11 @@ apt: name: - curl - state: "{{ apt_install_state | default('latest') }}" + state: "{{ package_install_state | default('latest') }}" update_cache: true cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" + when: + - ansible_os_family == 'Debian' - name: post | test installation command: > diff --git a/vars/_bionic.yml b/vars/_bionic.yml deleted file mode 100644 index 6fbcacc..0000000 --- a/vars/_bionic.yml +++ /dev/null @@ -1,27 +0,0 @@ -# vars file for tinyproxy ---- -tinyproxy_configuration_file: /etc/tinyproxy/tinyproxy.conf - -tinyproxy_tinyproxy_conf_preset: - - | - User tinyproxy - Group tinyproxy - Port {{ tinyproxy_port }} - Timeout 600 - DefaultErrorFile "/usr/share/tinyproxy/default.html" - StatFile "/usr/share/tinyproxy/stats.html" - Logfile "/var/log/tinyproxy/tinyproxy.log" - LogLevel Info - PidFile "/run/tinyproxy/tinyproxy.pid" - MaxClients 100 - MinSpareServers 5 - MaxSpareServers 20 - StartServers 10 - MaxRequestsPerChild 0 - {% for allow in tinyproxy_allow %} - Allow {{ allow }} - {% endfor %} - ViaProxyName "tinyproxy" - {% for connect_port in tinyproxy_connect_port %} - ConnectPort {{ connect_port }} - {% endfor %} diff --git a/vars/_default.yml b/vars/_default.yml deleted file mode 100644 index 364cc94..0000000 --- a/vars/_default.yml +++ /dev/null @@ -1,27 +0,0 @@ -# vars file for tinyproxy ---- -tinyproxy_configuration_file: /etc/tinyproxy.conf - -tinyproxy_tinyproxy_conf_preset: - - | - User nobody - Group nogroup - Port {{ tinyproxy_port }} - Timeout 600 - DefaultErrorFile "/usr/share/tinyproxy/default.html" - StatFile "/usr/share/tinyproxy/stats.html" - Logfile "/var/log/tinyproxy/tinyproxy.log" - LogLevel Info - PidFile "/var/run/tinyproxy/tinyproxy.pid" - MaxClients 100 - MinSpareServers 5 - MaxSpareServers 20 - StartServers 10 - MaxRequestsPerChild 0 - {% for allow in tinyproxy_allow %} - Allow {{ allow }} - {% endfor %} - ViaProxyName "tinyproxy" - {% for connect_port in tinyproxy_connect_port %} - ConnectPort {{ connect_port }} - {% endfor %} diff --git a/vars/_stretch.yml b/vars/_stretch.yml deleted file mode 100644 index 6fbcacc..0000000 --- a/vars/_stretch.yml +++ /dev/null @@ -1,27 +0,0 @@ -# vars file for tinyproxy ---- -tinyproxy_configuration_file: /etc/tinyproxy/tinyproxy.conf - -tinyproxy_tinyproxy_conf_preset: - - | - User tinyproxy - Group tinyproxy - Port {{ tinyproxy_port }} - Timeout 600 - DefaultErrorFile "/usr/share/tinyproxy/default.html" - StatFile "/usr/share/tinyproxy/stats.html" - Logfile "/var/log/tinyproxy/tinyproxy.log" - LogLevel Info - PidFile "/run/tinyproxy/tinyproxy.pid" - MaxClients 100 - MinSpareServers 5 - MaxSpareServers 20 - StartServers 10 - MaxRequestsPerChild 0 - {% for allow in tinyproxy_allow %} - Allow {{ allow }} - {% endfor %} - ViaProxyName "tinyproxy" - {% for connect_port in tinyproxy_connect_port %} - ConnectPort {{ connect_port }} - {% endfor %} diff --git a/vars/main.yml b/vars/main.yml deleted file mode 100644 index 0d671fc..0000000 --- a/vars/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -# vars file for tinyproxy ---- -tinyproxy_dependencies: - - tinyproxy