1 # Copyright (c) 2016-2017 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # must do this before setting yum proxy
16 - name: find yum/dnf config
17 stat: "path={{ item }}"
18 register: packager_conf_stat
23 - name: insert yum/dnf proxy(http)
24 # insert after [main] section
26 dest: "{{ item.stat.path }}"
28 regexp: "^proxy\\s*=\\s*{{ proxy_env.http_proxy }}"
29 insertafter: "^\\[main\\]"
30 line: "proxy={{ proxy_env.http_proxy }}"
31 when: '"http_proxy" in proxy_env and item.stat.isreg is defined and item.stat.isreg'
32 with_items: "{{ packager_conf_stat.results }}"
35 command: "grep proxy= {{ item.stat.path }}"
36 when: 'item.stat.isreg is defined and item.stat.isreg'
37 with_items: "{{ packager_conf_stat.results }}"
38 register: yum_proxy_lines
40 - name: yum disable fastest mirrors
41 include: yum_disable_fastestmirrors.yml
42 when: ansible_pkg_mgr == 'yum'
44 - name: Test proxy connection
45 # try workaround call makecache directly
46 # yum module was failing for some reason
47 async: "{{ connection_timeout }}"
48 command: "{{ ansible_pkg_mgr }} -d2 -y makecache"
50 register: test_proxy_job_id