Saltstack Official Linux Formula
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.

115 lines
2.5KB

  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.enabled %}
  3. {% set default_repos = {} %}
  4. {%- for name, repo in system.repo.iteritems() %}
  5. {%- if grains.os_family == 'Debian' %}
  6. {%- if repo.pin is defined %}
  7. linux_repo_{{ name }}_pin:
  8. file.managed:
  9. - name: /etc/apt/preferences.d/{{ name }}
  10. - source: salt://linux/files/preferences_repo
  11. - template: jinja
  12. - defaults:
  13. repo_name: {{ name }}
  14. {%- else %}
  15. linux_repo_{{ name }}_pin:
  16. file.absent:
  17. - name: /etc/apt/preferences.d/{{ name }}
  18. {%- endif %}
  19. {%- if repo.get('default', False) %}
  20. {%- do default_repos.update({name: repo}) %}
  21. {%- if repo.key_url|default(False) %}
  22. linux_repo_{{ name }}_key:
  23. cmd.wait:
  24. - name: "curl -s {{ repo.key_url }} | apt-key add -"
  25. - watch:
  26. - file: default_repo_list
  27. {%- endif %}
  28. {%- else %}
  29. linux_repo_{{ name }}:
  30. pkgrepo.managed:
  31. - human_name: {{ name }}
  32. - name: {{ repo.source }}
  33. {%- if repo.architectures is defined %}
  34. - architectures: {{ repo.architectures }}
  35. {%- endif %}
  36. - file: /etc/apt/sources.list.d/{{ name }}.list
  37. {%- if repo.key_id is defined %}
  38. - keyid: {{ repo.key_id }}
  39. {%- endif %}
  40. {%- if repo.key_server is defined %}
  41. - keyserver: {{ repo.key_server }}
  42. {%- endif %}
  43. {%- if repo.key_url is defined %}
  44. - key_url: {{ repo.key_url }}
  45. {%- endif %}
  46. - consolidate: {{ repo.get('consolidate', False) }}
  47. - clean_file: {{ repo.get('clean_file', False) }}
  48. - refresh_db: {{ repo.get('refresh_db', True) }}
  49. - require:
  50. - pkg: linux_packages
  51. {%- endif %}
  52. {%- endif %}
  53. {%- if grains.os_family == "RedHat" %}
  54. {%- if not repo.get('default', False) %}
  55. linux_repo_{{ name }}:
  56. pkgrepo.managed:
  57. - name: {{ name }}
  58. - humanname: {{ repo.get('humanname', name) }}
  59. {%- if repo.mirrorlist is defined %}
  60. - mirrorlist: {{ repo.mirrorlist }}
  61. {%- else %}
  62. - baseurl: {{ repo.source }}
  63. {%- endif %}
  64. - gpgcheck: {% if repo.get('gpgcheck', False) %}1{% else %}0{% endif %}
  65. {%- if repo.gpgkey is defined %}
  66. - gpgkey: {{ repo.gpgkey }}
  67. {%- endif %}
  68. - require:
  69. - pkg: linux_packages
  70. {%- endif %}
  71. {%- endif %}
  72. {%- endfor %}
  73. {%- if default_repos|length > 0 and grains.os_family == 'Debian' %}
  74. default_repo_list:
  75. file.managed:
  76. - name: /etc/apt/sources.list
  77. - source: salt://linux/files/sources.list
  78. - template: jinja
  79. - user: root
  80. - group: root
  81. - mode: 0644
  82. - defaults:
  83. default_repos: {{ default_repos }}
  84. - require:
  85. - pkg: linux_packages
  86. {%- endif %}
  87. {%- endif %}