diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..33529f5 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handler file for terraform_agent + +- name: Restart the Terraform Agent + ansible.builtin.service: + name: tfc-agent + state: restarted + when: + - terraform_agent_token is defined + - terraform_agent_token != "" + diff --git a/tasks/main.yml b/tasks/main.yml index 71d3173..a304a33 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -25,6 +25,8 @@ src: "https://releases.hashicorp.com/tfc-agent/{{ terraform_agent_version }}/tfc-agent_{{ terraform_agent_version }}_linux_amd64.zip" dest: "{{ terraform_agent_installation_path }}" remote_src: true + notify: + - Restart the Terraform Agent - name: Place environment variable file ansible.builtin.template: @@ -33,6 +35,8 @@ mode: 0644 owner: root group: root + notify: + - Restart the Terraform Agent - name: Place a service file for Terraform Agent ansible.builtin.template: @@ -41,6 +45,8 @@ mode: 0644 owner: root group: root + notify: + - Restart the Terraform Agent - name: Start the Terraform Agent ansible.builtin.service: