diff --git a/multi-node-aio-xenial-ansible/roles/proxy_install/README.md b/multi-node-aio-xenial-ansible/roles/proxy_install/README.md new file mode 100644 index 00000000..1a1530f9 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/proxy_install/README.md @@ -0,0 +1,28 @@ +proxy_install +========= + +This module sets up a web and apt proxy on Ubuntu 16 + +Requirements +------------ + +This module requires Ansible 2.x + +Role Variables +-------------- + +See defaults for variables and descriptions + +Dependencies +------------ + +This role has no dependencies + +Example Playbook +---------------- + +Example to call: + + - hosts: all + roles: + - { role: proxy_install } diff --git a/multi-node-aio-xenial-ansible/roles/proxy_install/defaults/main.yml b/multi-node-aio-xenial-ansible/roles/proxy_install/defaults/main.yml new file mode 100644 index 00000000..7ee19479 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/proxy_install/defaults/main.yml @@ -0,0 +1,23 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# name: proxy_install/defaults +# description: ALL our default variables for proxy_install go in here +#------------------------------------------------------------------------------ +# Packages - All our required packages we need installing +#------------------------------------------------------------------------------ + +# - Proxy URL - +proxy: http://proxy.example.com:8080 # Example proxy URL +environment_path: /etc/environment # Default path for environment +apt_proxy_path: /etc/apt/apt.conf.d/80proxy # Default path for apt proxy diff --git a/multi-node-aio-xenial-ansible/roles/proxy_install/meta/main.yml b/multi-node-aio-xenial-ansible/roles/proxy_install/meta/main.yml new file mode 100644 index 00000000..fe3e481e --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/proxy_install/meta/main.yml @@ -0,0 +1,22 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +galaxy_info: + author: "Rick Box - BBC R&D" + license: Apache2 + min_ansible_version: 2.0 + platforms: + - name: Ubuntu + versions: + - xenial +dependencies: [] diff --git a/multi-node-aio-xenial-ansible/roles/proxy_install/tasks/configure.yml b/multi-node-aio-xenial-ansible/roles/proxy_install/tasks/configure.yml new file mode 100644 index 00000000..7bb45ff7 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/proxy_install/tasks/configure.yml @@ -0,0 +1,37 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# module: proxy_install/tasks/configure +# description: Configure proxy_install + +- name: Setup http proxy for APT + template: + src: 80proxy.j2 + dest: "{{ apt_proxy_path }}" + mode: 0644 + owner: root + group: root + +- name: Setup http proxy environment variables + lineinfile: + dest: "{{ environment_path }}" + line: "{{ item.line }}" + regexp: "{{ item.regexp }}" + with_items: + - { line: "http_proxy={{ proxy }}", regexp: "^http_proxy=" } + - { line: "https_proxy={{ proxy }}", regexp: "^https_proxy=" } + - { line: "RSYNC_PROXY={{ proxy }}", regexp: "^RSYNC_PROXY=" } + +- name: Change current environment variables, change disabled since it runs each time + shell: "export http_proxy={{ proxy }}; export https_proxy={{ proxy }}; export RSYNC_PROXY={{ proxy }}" + changed_when: false diff --git a/multi-node-aio-xenial-ansible/roles/proxy_install/tasks/main.yml b/multi-node-aio-xenial-ansible/roles/proxy_install/tasks/main.yml new file mode 100644 index 00000000..b75c3f89 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/proxy_install/tasks/main.yml @@ -0,0 +1,17 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# module: proxy_install/tasks +# description: Install proxy_install onto an Ubuntu 16.xx server + +- include: configure.yml diff --git a/multi-node-aio-xenial-ansible/roles/proxy_install/templates/80proxy.j2 b/multi-node-aio-xenial-ansible/roles/proxy_install/templates/80proxy.j2 new file mode 100644 index 00000000..af4314c4 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/proxy_install/templates/80proxy.j2 @@ -0,0 +1,2 @@ +### MANAGED BY {{ role_path|basename }} ANSIBLE ROLE ### +Acquire::http::Proxy "{{ proxy }}";