From eaa8dceca1c605febd2e211f44d005b13890e0c3 Mon Sep 17 00:00:00 2001 From: Jostein Martinsen Date: Wed, 23 Oct 2019 10:23:35 +0200 Subject: [PATCH 1/4] Halfway there. Need to push the changes --- Vagrantfile | 25 +++++++++++----------- defaults/main.yml | 32 ++++++++++++++++++++++++++++ tasks/main.yml | 53 +++++++++++++++++++++++++++++++++-------------- tests/post.yml | 2 +- vars/_bionic.yml | 27 ------------------------ vars/_default.yml | 27 ------------------------ vars/_stretch.yml | 27 ------------------------ vars/main.yml | 4 ---- 8 files changed, 83 insertions(+), 114 deletions(-) delete mode 100644 vars/_bionic.yml delete mode 100644 vars/_default.yml delete mode 100644 vars/_stretch.yml delete mode 100644 vars/main.yml diff --git a/Vagrantfile b/Vagrantfile index 5e3d836..839035a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,13 +4,6 @@ role = File.basename(File.expand_path(File.dirname(__FILE__))) boxes = [ - { - :name => "ubuntu-1404", - :box => "bento/ubuntu-14.04", - :ip => '10.0.0.12', - :cpu => "50", - :ram => "256" - }, { :name => "ubuntu-1604", :box => "bento/ubuntu-16.04", @@ -23,22 +16,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..a4d1e7d 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 "/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/main.yml b/tasks/main.yml index 63ba921..071cc62 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,22 +1,41 @@ # 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: include variables +# include_vars: "{{ item }}" +# with_first_found: +# - "_{{ ansible_os_family }}.yml" +# - "_{{ ansible_distribution_release }}.yml" +# - "_{{ ansible_distribution | lower }}.yml" +# - _default.yml +# tags: +# - configuration +# - tinyproxy +# - tinyproxy-include-variables + +- name: Set fact for Debian + set_fact: + tinyproxy_configuration_file: /etc/tinyproxy.conf + proxy_user: nobody + proxy_group: nogroup + when: + - ansible_distribution == "Ubuntu" + - ansible_distribution_major_version == "16" + +- name: RedHat | Install the latest version of Tinyproxy + yum: + name: "{{ tinyproxy_dependencies }}" + state: "{{ package_install_state | default('latest') }}" + enablerepo: epel + when: + - ansible_os_family == 'RedHat' + +- name: Debian | Install the latest version of Tinyproxy + package: name: "{{ tinyproxy_dependencies }}" - state: "{{ apt_install_state | default('latest') }}" - update_cache: true - cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" + state: "{{ package_install_state | default('latest') }}" + when: + - ansible_os_family == 'Debian' tags: - configuration - tinyproxy @@ -25,7 +44,9 @@ - name: install additional apt: name: "{{ tinyproxy_install }}" - state: "{{ apt_install_state | default('latest') }}" + state: "{{ package_install_state | default('latest') }}" + when: + - ansible_os_family == 'Debian' tags: - configuration - tinyproxy diff --git a/tests/post.yml b/tests/post.yml index 063ff90..b4b38e5 100644 --- a/tests/post.yml +++ b/tests/post.yml @@ -4,7 +4,7 @@ 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) }}" 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 From f2c1e93d5967de57fec2611a91f995e1c289ba32 Mon Sep 17 00:00:00 2001 From: Jostein Martinsen Date: Wed, 23 Oct 2019 11:47:17 +0200 Subject: [PATCH 2/4] Done with fixing bugs for all vagrant boxes --- defaults/main.yml | 2 +- tasks/Debian.yml | 44 ++++++++++++++++++++++++++++++++ tasks/RedHat.yml | 32 +++++++++++++++++++++++ tasks/main.yml | 65 +++++++++++++---------------------------------- tests/post.yml | 2 ++ 5 files changed, 96 insertions(+), 49 deletions(-) create mode 100644 tasks/Debian.yml create mode 100644 tasks/RedHat.yml diff --git a/defaults/main.yml b/defaults/main.yml index a4d1e7d..2506f53 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -29,7 +29,7 @@ tinyproxy_tinyproxy_conf_preset: StatFile "/usr/share/tinyproxy/stats.html" Logfile "/var/log/tinyproxy/tinyproxy.log" LogLevel Info - PidFile "/run/tinyproxy/tinyproxy.pid" + PidFile "{{ pidfile | default("/run/tinyproxy/tinyproxy.pid") }}" MaxClients 100 MinSpareServers 5 MaxSpareServers 20 diff --git a/tasks/Debian.yml b/tasks/Debian.yml new file mode 100644 index 0000000..71f1abb --- /dev/null +++ b/tasks/Debian.yml @@ -0,0 +1,44 @@ +--- + +# 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 == "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..9c6bdf2 --- /dev/null +++ b/tasks/RedHat.yml @@ -0,0 +1,32 @@ +--- + +- 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 071cc62..89be49b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,56 +1,25 @@ # tasks file for tinyproxy --- -# - name: include variables -# include_vars: "{{ item }}" -# with_first_found: -# - "_{{ ansible_os_family }}.yml" -# - "_{{ ansible_distribution_release }}.yml" -# - "_{{ ansible_distribution | lower }}.yml" -# - _default.yml -# tags: -# - configuration -# - tinyproxy -# - tinyproxy-include-variables - -- name: Set fact for Debian - set_fact: - tinyproxy_configuration_file: /etc/tinyproxy.conf - proxy_user: nobody - proxy_group: nogroup - when: - - ansible_distribution == "Ubuntu" - - ansible_distribution_major_version == "16" - -- name: RedHat | Install the latest version of Tinyproxy - yum: - name: "{{ tinyproxy_dependencies }}" - state: "{{ package_install_state | default('latest') }}" - enablerepo: epel - when: - - ansible_os_family == 'RedHat' - -- name: Debian | Install the latest version of Tinyproxy - package: - name: "{{ tinyproxy_dependencies }}" - state: "{{ package_install_state | default('latest') }}" - when: - - ansible_os_family == 'Debian' +- debug: + msg: "{{ hostvars[inventory_hostname].ansible_distribution }}" tags: - - configuration - - tinyproxy - - tinyproxy-dependencies - -- name: install additional - apt: - name: "{{ tinyproxy_install }}" - state: "{{ package_install_state | default('latest') }}" - when: - - ansible_os_family == 'Debian' + - 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 b4b38e5..7cd100b 100644 --- a/tests/post.yml +++ b/tests/post.yml @@ -7,6 +7,8 @@ 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: > From d6659582d5a5f1c588c3ad7a3cfb0c3363501473 Mon Sep 17 00:00:00 2001 From: Jostein Martinsen Date: Wed, 23 Oct 2019 13:14:08 +0200 Subject: [PATCH 3/4] Added Ubuntu 14.04 again --- Vagrantfile | 7 +++++++ tasks/Debian.yml | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 839035a..5b68c79 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,6 +4,13 @@ role = File.basename(File.expand_path(File.dirname(__FILE__))) boxes = [ + { + :name => "ubuntu-1404", + :box => "bento/ubuntu-14.04", + :ip => '10.0.0.12', + :cpu => "50", + :ram => "256" + }, { :name => "ubuntu-1604", :box => "bento/ubuntu-16.04", diff --git a/tasks/Debian.yml b/tasks/Debian.yml index 71f1abb..310a50f 100644 --- a/tasks/Debian.yml +++ b/tasks/Debian.yml @@ -7,7 +7,8 @@ tinyproxy_configuration_file: /etc/tinyproxy.conf proxy_user: nobody proxy_group: nogroup - when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "16") or + 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 From 48f7fd344122b4b9e05d1118f436491d430f733f Mon Sep 17 00:00:00 2001 From: Jostein Martinsen Date: Wed, 23 Oct 2019 13:21:33 +0200 Subject: [PATCH 4/4] Passing lint checks --- tasks/Debian.yml | 8 ++++---- tasks/RedHat.yml | 13 ++++++------- tasks/main.yml | 2 +- tests/post.yml | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tasks/Debian.yml b/tasks/Debian.yml index 310a50f..e1b9d98 100644 --- a/tasks/Debian.yml +++ b/tasks/Debian.yml @@ -9,7 +9,7 @@ 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") + (ansible_distribution == "Debian" and ansible_distribution_major_version == "8") - name: Set facts for Ubuntu 18 and Debian 9 set_fact: @@ -18,14 +18,14 @@ 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") + (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: + when: - ansible_os_family == 'Debian' tags: - configuration @@ -36,7 +36,7 @@ apt: name: "{{ tinyproxy_install }}" state: "{{ package_install_state | default('latest') }}" - when: + when: - ansible_os_family == 'Debian' tags: - configuration diff --git a/tasks/RedHat.yml b/tasks/RedHat.yml index 9c6bdf2..00753ce 100644 --- a/tasks/RedHat.yml +++ b/tasks/RedHat.yml @@ -3,15 +3,15 @@ - name: Set fact for CentOS 7 set_fact: gpgkey: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 - when: - - ansible_distribution == "CentOS" + 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" + when: + - ansible_distribution == "CentOS" - ansible_distribution_major_version == "8" - name: RedHat | Install epel-release @@ -20,13 +20,12 @@ 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: + when: - ansible_os_family == 'RedHat' - name: RedHat | Install the latest version of Tinyproxy yum: name: "{{ tinyproxy_dependencies }}" state: "{{ package_install_state | default('latest') }}" - when: + when: - ansible_os_family == 'RedHat' - diff --git a/tasks/main.yml b/tasks/main.yml index 89be49b..af423b8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -18,7 +18,7 @@ - never - name: include OS specific tasks - include_tasks: "{{ansible_os_family}}.yml" + include_tasks: "{{ ansible_os_family }}.yml" - name: update configuration file diff --git a/tests/post.yml b/tests/post.yml index 7cd100b..a2c64bf 100644 --- a/tests/post.yml +++ b/tests/post.yml @@ -7,7 +7,7 @@ state: "{{ package_install_state | default('latest') }}" update_cache: true cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" - when: + when: - ansible_os_family == 'Debian' - name: post | test installation