Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add opts to repo name #31

Merged
merged 5 commits into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ and ``man 5 apt_preferences`` for an explanation about the resulting files struc
Installs ``python-software-properties``
(``$ /usr/bin/apt-add-repository ppa:user/repository``).

``apt.unattended``
------------------
Installs and configures ``unattended-upgrades``

``apt.transports.debtorrent``
-------------------------------
Expand Down
3 changes: 2 additions & 1 deletion apt/repositories.sls
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ debian-archive-keyring:
{%- set r_arch = '[arch=' ~ args.arch|join(',') ~ ']' if args.arch is defined else '' %}
{%- set r_url = args.url or default_url %}
{%- set r_distro = args.distro or 'stable' %}
{%- set r_opts = args.opts if args.opts is defined else '' %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand from the manpage, the format is

deb [arch=i386 trusted=yes another=whatever] http://deb.debian.org/debian stable contrib non-free main

and not

deb [arch=i386] [trusted=yes another=whatever] http://deb.debian.org/debian stable contrib non-free main

so I think that we should merge r_arch and r_opts if the latter is set. Perhaps we can turn it a hash parameter, like

...
opts:
  trusted: 'yes'
  another: whatever
...
{% set r_opts = '' %}

{%- set r_arch = 'arch=' ~ args.arch|join(',') if args.arch is defined else '' %}
{% if args.opts is defined %}
  {% if args.opts is string %}
    {% set r_opts = args.opts %}
  {% else %}
    {%- for k, v in args.opts.items() %}
      {% set r_opts = r_opts ~ ' ' ~ k ~ '=' ~ v %}
    {%- endfor %}
  {% endif %}
{% endif %}

{% if r_arch != '' or r_opts ! = '' %}
  {% set r_options = '[' ~ r_arch ~ ' ' ~ r_opts ~ ']'
{% else %}
  {% set r_options = ''
{% endif %}
...
...
  pkgrepo.managed:
    - name: {{ r_type }} {{ r_options }} {{ r_url }} {{ r_distro }} {{ r_comps }}

what do you think? Haven't tested this, is just a 'before my 1st. coffee' idea, so maybe it's wrong 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javierbertoli looks good, I hadn't seen that bit of the documentation but you're absolutely right. I'm going to try out your code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appart from small typos, it works for the string pillar, but not the dict pillar (the for k, v in args.opts.items() doesn't seem to work. Is it a jinja local variable problem ?

{%- set r_comps = args.comps|default(['main'])|join(' ') %}
{%- set r_keyserver = args.keyserver if args.keyserver is defined else apt_map.default_keyserver %}

Expand All @@ -38,7 +39,7 @@ debian-archive-keyring:

{{ r_type }} {{ repo }}:
pkgrepo.managed:
- name: {{ r_type }} {{ r_arch }} {{ r_url }} {{ r_distro }} {{ r_comps }}
- name: {{ r_type }} {{ r_arch }} {{ r_opts }} {{ r_url }} {{ r_distro }} {{ r_comps }}
- file: {{ sources_list_dir }}/{{ repo }}-{{ type }}.list
{# You can use either keyid+keyserver or key_url. If both are provided
the latter will be used. #}
Expand Down
4 changes: 4 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ apt:
arch: [i386, amd64]
keyid: 1C61A2656FB57B7E4DE0F4C1FC918B335044912E
keyserver: hkp://pgp.mit.edu:80
intranet:
distro: stretch
url: http://intranet.example.org
opts: "[trusted=yes]"

preferences:
00-rspamd:
Expand Down