ansible-role-systemd-service icon indicating copy to clipboard operation
ansible-role-systemd-service copied to clipboard

Add include_role example

Open abh opened this issue 7 years ago • 1 comments

I'm trying to use this from another role, but just get errors. A correct example in the readme would be helpful!

- name: setup nsd_exporter service
  include_role:
    name: tumf.systemd-service
  vars:
    systemd_service_name: "nsd_exporter"
    systemd_service_Service_ExecStart: "/opt/bin/nsd_exporter"

gives me this error:

ERROR! Invalid options for include_role: systemd_service_Service_ExecStart,systemd_service_name

I realize this isn't a problem with the role but really me not understanding the ansible documentation, but I thought still an example in the README here would be useful as I am guessing this might be a common use case. :-)

abh avatar Jul 24 '18 08:07 abh

nope, sometimes I get this error

FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'systemd_service_name' is undefined\n\nThe error appears to have been in '/Users/ask/src/bitnames-ansible/roles/tumf.systemd-service/tasks/main.yml': line 8, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- template: src=\"default.j2\" dest=\"{{ ansible_unit_test_prefix_dir }}/{{ systemd_service_default_dir }}/{{ systemd_service_name }}\"\n  ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes.  Always quote template expression brackets when they\nstart a value. For instance:\n\n    with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    with_items:\n      - \"{{ foo }}\"\n"}

abh avatar Jul 24 '18 09:07 abh