tcconfig icon indicating copy to clipboard operation
tcconfig copied to clipboard

Ansible Module

Open rabin-io opened this issue 4 years ago • 4 comments

Hi,

First I like to thank you for this project, which make working with tc much more sane for us mortals.

One thing I like to ask is if you would consider porting the code base into an Ansible Module ? I started testing this with a client side support where tcconfig is installed on the destination machine. And I have as small lib which I was able to compile from several places which tried to do the same, which works for my small use case, but I think that having the support directly as ansible module/lib which compile the commands on the managing host and push the required commands to the provisioned machine is the right why to accomplish this.

---
- hosts: all
  become: True
  user: vagrant
  vars:
    ansible_python_interpreter: /usr/bin/python
  tasks:

    - tc:
        device: eth1
        loss: 30%
        delay: 70ms
        delay_distro: 30ms
        dst_network: 192.168.56.202

rabin-io avatar Jan 02 '20 21:01 rabin-io

Hi,

Thank you for your feedback and information.

It looks interesting. However, I'm not familiar with Ansible module development, so let me clarify your expectations. Did you expect me to take over your module development, and fill out module info then make a PR to Ansible repository? Are there any test codes for the module?

thombashi avatar Jan 05 '20 03:01 thombashi

Hi,

I was more thinking you can write a better version for this module, as my experience with Python is almost zero to none, and the above gist was hacked by looking on the Ansible Module development example.

I see this like this... The Ansible Module abstract the configuration of using tc, much like the CLI format you have provided to simplify the usage of tc and apply the command on the managed machine. Since Ansible is Python based just like your library/tool I was thinking that would be a "easy" task. The thing is that Ansible modules need to be consistent so that it should only change when there is something to change and bring the system to the desired state, just like you have implemented the overwrite/change/add options.

My thinking was to have a module which only need the library installed on the manage machine, which compile the commands and push/run them on the remote machine. But that was over my head, so I installed tcconfig on the remote machine and compiled the tcset command line and pushed it to the machine and run the command as is with overwrite option.

I know I'm asking for a lot, but that was my wish for "Ansible Module" for tc

rabin-io avatar Jan 05 '20 10:01 rabin-io

Thank you for your detailed explanation.

Looks like this will need more investigation. I'm not sure this would even be possible or not.

tcconfig client/server #128 can be used for setup shaping rules to remote hosts.

thombashi avatar Jan 28 '20 15:01 thombashi

Hi,

The option to import external libs are there ... but I won't know what to do with it.

rabin-io avatar Jan 28 '20 16:01 rabin-io