Squid role, first bits.

This commit is contained in:
Andrea Dell'Amico 2020-05-04 19:13:03 +02:00
parent 3e9ccbe40f
commit 99f67c7a12
6 changed files with 117 additions and 76 deletions

View File

@ -1,38 +1,16 @@
Role Name
squid
=========
A brief description of the role goes here.
This role installs and configures the squid caching proxy, <http://www.squid-cache.org/>
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
EUPL-1.2
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Andrea Dell'Amico, <andrea.dellamico@isti.cnr.it>

View File

@ -1,2 +1,14 @@
---
# defaults file for ansible-role-template
squid_install: True
squid_local_nets:
- '127.0.0.1/8'
squid_ssl_ports:
- 443
squid_safe_ports:
- 80
- 443
squid_max_object_size: '10 MB'
squid_disk_cache: '2048 16 256'

View File

@ -1,2 +1,4 @@
---
# handlers file for ansible-role-template
- name: Reload squid
service: name=squid state=reloaded

View File

@ -1,61 +1,23 @@
galaxy_info:
author: your name
description: your description
author: Andrea Dell'Amico
description: Systems Architect
company: ISTI-CNR
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: EUPL 1.2+
min_ansible_version: 2.8
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
platforms:
- name: EL
versions:
- 7
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
galaxy_tags:
- squid
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View File

@ -1,2 +1,20 @@
---
# tasks file for ansible-role-template
- block:
- name: Install the squid package
yum: pkg=squid state=present
when:
- ansible_distribution_file_variety == "RedHat"
- squid_install | bool
tags: [ 'squid', 'proxy' ]
- block:
- name: Install the squid configuration file
template: src=squid.conf.j2 dest=/etc/squid/squid.conf
notify: Reload squid
- name: Ensure that the squid service is running and enabled
service: name=squid state=started enabled=yes
when: squid_install | bool
tags: [ 'squid', 'proxy' ]

69
templates/squid.conf.j2 Normal file
View File

@ -0,0 +1,69 @@
#
# Recommended minimum configuration:
#
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
{% for net in squid_local_nets %}
acl localnet src {{ net }}
{% endfor %}
{% for ssl_port in squid_ssl_ports %}
acl SSL_ports port {{ ssl_port }}
{% endfor %}
{% for port in squid_safe_ports %}
acl Safe_ports port {{ port }}
{% endfor %}
acl CONNECT method CONNECT
#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost
# And finally deny all other access to this proxy
http_access deny all
# Squid normally listens to port 3128
http_port 3128
maximum_object_size {{ squid_max_object_size }}
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid {{ squid_disk_cache }}
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320