iamckn/wireguard_ansible

Refactoring: Keys and client files should be iterated over, not handled manually

Closed this issue · 1 comments

kjgd commented

Rather than doing one_private key, two_private_key or having to individually do Generate client one config, Generate client two config, we should be able to:

  • access keys by either a name or an index, so priv_key[1] or priv_key['one'] instead of one_private_key, and
  • use one task to handle repetitive client config generation, such as
- name: Generate client configs
  template:
    src: "templates/{{item}}.conf"
    dest: "~/{{item}}.conf"
    owner: root
    group: root
    mode: 0600
  with_items:
    - one
    - two
    - three
    - four

instead of doing:

  - name: Generate client one config
    template:
      src: "templates/one.conf"
      dest: "~/one.conf"
      owner: root
      group: root
      mode: 0600

  - name: Generate client two config
    template:
      src: "templates/two.conf"
      dest: "~/two.conf"
      owner: root
      group: root
      mode: 0600

Changes have been made to use one template client config for the generation of a specified number of client profiles.