|
| 1 | +--- |
| 2 | + |
| 3 | + - set_fact: |
| 4 | + b1: [] |
| 5 | + b2: [] |
| 6 | + b3: [] |
| 7 | + |
| 8 | + # |
| 9 | + # /etc/environment |
| 10 | + # |
| 11 | + - name: Create the environment block |
| 12 | + set_fact: |
| 13 | + b1: "{{ b1 }} + ['{{ item }}=http://{{ proxy_addr }}:{{ proxy_port }}/']" |
| 14 | + with_items: |
| 15 | + - http_proxy |
| 16 | + - https_proxy |
| 17 | + - ftp_proxy |
| 18 | + - HTTP_PROXY |
| 19 | + - HTTPS_PROXY |
| 20 | + - FTP_PROXY |
| 21 | + |
| 22 | + - name: Append to the environment block |
| 23 | + set_fact: |
| 24 | + b1: "{{ b1 }} + ['{{ item }}=\"localhost,127.0.0.1,localaddress,.localdomain.com\"']" |
| 25 | + with_items: |
| 26 | + - no_proxy |
| 27 | + - NO_PROXY |
| 28 | + |
| 29 | + - name: Update /etc/environment |
| 30 | + blockinfile: |
| 31 | + dest: /etc/environment |
| 32 | + block: "{{ b1 | join('\n') }}" |
| 33 | + insertafter: EOF |
| 34 | + marker: "# {mark} ANSIBLE MANAGED BLOCK - PROXY" |
| 35 | + become: true |
| 36 | + |
| 37 | + # |
| 38 | + # /etc/profile.d/proxy.sh |
| 39 | + # |
| 40 | + |
| 41 | + - name: Create the profile block |
| 42 | + set_fact: |
| 43 | + b2: "{{ b2 }} + ['export {{ item.opt }}={{ item.prot }}://{{ proxy_addr }}:{{ proxy_port }}/']" |
| 44 | + with_items: |
| 45 | + - {opt: http_proxy, prot: http} |
| 46 | + - {opt: https_proxy, prot: http} |
| 47 | + - {opt: ftp_proxy, prot: http} |
| 48 | + - {opt: socks_proxy,prot: socks} |
| 49 | + - {opt: npm_config_proxy, prot: http} |
| 50 | + - {opt: npm_config_https_proxy, prot: http} |
| 51 | + |
| 52 | + - name: Update /etc/profile.d/proxy.sh |
| 53 | + blockinfile: |
| 54 | + dest: /etc/profile.d/proxy.sh |
| 55 | + block: "{{ b2 | join('\n') }}" |
| 56 | + insertafter: EOF |
| 57 | + marker: "# {mark} ANSIBLE MANAGED BLOCK - PROXY" |
| 58 | + become: true |
| 59 | + |
| 60 | + # |
| 61 | + # /etc/apt/apt.conf.d/80proxy |
| 62 | + # |
| 63 | + |
| 64 | + - name: Create the apt.conf block |
| 65 | + set_fact: |
| 66 | + b3: "{{ b3 }} + ['{{ item }};']" |
| 67 | + with_items: |
| 68 | + - Acquire::http::proxy "http://{{ proxy_addr }}:{{ proxy_port }}/" |
| 69 | + - Acquire::ftp::proxy "ftp://{{ proxy_addr }}:{{ proxy_port }}/" |
| 70 | + - Acquire::https::proxy "https://{{ proxy_addr }}:{{ proxy_port }}/" |
| 71 | + |
| 72 | + - name: Update /etc/apt/apt.conf.d/80proxy |
| 73 | + blockinfile: |
| 74 | + dest: /etc/apt/apt.conf.d/80proxy |
| 75 | + block: "{{ b3 | join('\n') }}" |
| 76 | + insertafter: EOF |
| 77 | + marker: "# {mark} ANSIBLE MANAGED BLOCK - PROXY" |
| 78 | + become: true |
| 79 | + |
| 80 | + # |
| 81 | + # git |
| 82 | + # |
| 83 | + |
| 84 | + - name: Add proxy to git |
| 85 | + shell: git config --global {{ item.opt }} {{ item.prot }}://{{ proxy_addr }}:{{ proxy_port }} |
| 86 | + with_items: |
| 87 | + - { opt: http.proxy, prot: http } |
| 88 | + - { opt: https.proxy, prot: https } |
| 89 | + |
| 90 | + - name: Set git to https |
| 91 | + shell: git config --global url."https://github.com/".insteadOf git://github.com/ |
0 commit comments