Skip to content

Provide feedback#18

Open
bill-n wants to merge 12 commits intomasterfrom
provide_feedback
Open

Provide feedback#18
bill-n wants to merge 12 commits intomasterfrom
provide_feedback

Conversation

@bill-n
Copy link

@bill-n bill-n commented Jun 22, 2020

SUMMARY

Whenever one runs a terraform apply or destroy command, one does not get a real time feedback as to what is happening at the background . So the terraform module has been modified and a customized plugin called terraform_stream has been added to the module to enable one to get a realtime output when one runs a terraform apply or destroy.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

terraform module
terraform_stream plugin

ADDITIONAL INFORMATION

On start of the playbook, the callback plugin starts a daemonized UDP socket server and then the terraform tasks would then execute and send output to the plugin.
The callback plugin reads the socket port and host from an environment variable
ANSIBLE_TERRAFORM_STREAM_PORT={port number}
ANSIBLE_TERRAFORM_STREAM_HOST={ip of the control node}

playbook.yml

- name: terraform real time feedback
    terraform:
      project_path: 'path_to_project/'
      state: present
      stream_output: True 

ansible.cfg

[defaults]
callback_whitelist = terraform_stream



def sample_server(display_self):
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

Choose a reason for hiding this comment

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

We might be able to do this without explicit configuration. If you bind to any available port on the local host here, you can then pass the port you get, to the code that writes. I believe that binding to port 0 will give you an 'available' port, which you can find with a getsockname() call. I think you can use INADDR_ANY for the hostname in the socket bind, to bind to all local addresses. The writer then just has to send to the IP of the controller which you should be able to find in code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants