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

Fixups for running in switch mode #54

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions tasks/tinc_configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
command: awk '/^-----END RSA PUBLIC KEY-----$/' /etc/tinc/{{ tinc_netname }}/hosts/{{ inventory_hostname | replace('.','_') | replace('-','_') }}
changed_when: "public_key.stdout != '-----END RSA PUBLIC KEY-----'"
register: public_key
ignore_errors: yes
Copy link
Owner

Choose a reason for hiding this comment

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

could you do failed_when: false instead?

Alternatively, what do you think of moving this task as a lineinfile with check_mode: yes? That might be better?

Copy link
Author

Choose a reason for hiding this comment

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

I think changed_when is appropriate here; the issue is that awk fails, and then no further tasks get executed for that host. Apologies for being a little unclear.

I'll try the lineinfile approach, as it seems like it could be cleaner if it works :)

Copy link
Author

Choose a reason for hiding this comment

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

Nevermind, I was misunderstanding failed_when. Will give that a go also.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for the help!


# this is necessary because the public key will not be generated (non-interactively) if the private key already exists
- name: delete private key and regenerate keypair if public key is absent from tinc hosts file
Expand Down
1 change: 1 addition & 0 deletions templates/tinc.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Name = {{ inventory_hostname | replace('.','_') | replace('-','_') }}
{% if tinc_address_family is defined %}
AddressFamily = {{ tinc_address_family }}
{% endif %}
Mode = {{ tinc_mode }}
Interface = {{ tinc_vpn_interface }}
{% for host in groups['tinc_spine_nodes'] %}
{% if inventory_hostname != hostvars[host]['inventory_hostname'] and inventory_hostname in groups['tinc_leaf_nodes'] %}
Expand Down