You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.9 KiB

  1. ---
  2. - name: List ubuntu_packages
  3. set_fact:
  4. ubuntu_packages:
  5. - python
  6. - python-apt
  7. - python-pip
  8. - dbus
  9. - name: Check if bootstrap is needed
  10. raw: dpkg -l | cut -d' ' -f3 | grep -e ^{{ item }}$
  11. register: need_bootstrap
  12. failed_when: false
  13. changed_when: false
  14. # This command should always run, even in check mode
  15. check_mode: false
  16. with_items: "{{ ubuntu_packages }}"
  17. environment: {}
  18. tags:
  19. - facts
  20. - name: Check http::proxy in /etc/apt/apt.conf
  21. raw: grep -qsi 'Acquire::http::proxy' /etc/apt/apt.conf
  22. register: need_http_proxy
  23. failed_when: false
  24. changed_when: false
  25. # This command should always run, even in check mode
  26. check_mode: false
  27. environment: {}
  28. when:
  29. - http_proxy is defined
  30. - name: Add http_proxy to /etc/apt/apt.conf if http_proxy is defined
  31. raw: echo 'Acquire::http::proxy "{{ http_proxy }}";' >> /etc/apt/apt.conf
  32. become: true
  33. environment: {}
  34. when:
  35. - http_proxy is defined
  36. - need_http_proxy.rc != 0
  37. - name: Check https::proxy in /etc/apt/apt.conf
  38. raw: grep -qsi 'Acquire::https::proxy' /etc/apt/apt.conf
  39. register: need_https_proxy
  40. failed_when: false
  41. changed_when: false
  42. # This command should always run, even in check mode
  43. check_mode: false
  44. environment: {}
  45. when:
  46. - https_proxy is defined
  47. - name: Add https_proxy to /etc/apt/apt.conf if https_proxy is defined
  48. raw: echo 'Acquire::https::proxy "{{ https_proxy }}";' >> /etc/apt/apt.conf
  49. become: true
  50. environment: {}
  51. when:
  52. - https_proxy is defined
  53. - need_https_proxy.rc != 0
  54. - name: Install python and pip
  55. raw:
  56. apt-get update && \
  57. DEBIAN_FRONTEND=noninteractive apt-get install -y {{ ubuntu_packages | join(" ") }}
  58. become: true
  59. environment: {}
  60. when:
  61. - need_bootstrap.results | map(attribute='rc') | sort | last | bool
  62. - set_fact:
  63. ansible_python_interpreter: "/usr/bin/python"
  64. tags:
  65. - facts