--- - name: Config proxy for apt copy: content: | Acquire::http::Proxy "{{ system_proxy }}"; Acquire::https::Proxy "{{ system_proxy }}"; dest: /etc/apt/apt.conf.d/10proxy when: - system_proxy is defined - system_proxy != '' tags: proxy - name: Remove proxy from apt config file: path=/etc/apt/apt.conf.d/10proxy state=absent when: system_proxy is not defined or system_proxy == '' tags: proxy