Let’s say you are running a freestyle project in jenkins and you need a variable to use between building steps. One way is to install and use different plugins to give you the option to add custom global variables. However, there is an alternative by using linux bash commands without any further installations. (this assumes that jenkins is running on linux. Same can be applied to windows with the appropriate syntax change)
Inside a jenkins freestyle project, each “Execute Shell” box works as an individual bash script running in the workspace. It not only works for running arbitrary commands:
but also to write a full bash script:
You can then create a variable in one shell step, save it as text in the workspace and open it later in a different step using native bash:
very useful when you need unique variables or identifiers per run, with multiple steps doing different stuff.
Give you only the definition of the module class: class ansible.module_utils.basic.AnsibleModule(argument_spec, bypass_checks=False, no_log=False, check_invalid_arguments=None, mutually_exclusive=None, required_together=None, required_one_of=None, add_file_common_args=False, supports_check_mode=False, required_if=None, required_by=None)
Here a useful blog that explains some of the options:
And some extra notes about required_if: Make sure you are consistent with the lists required. If you write:
required_if=[['show_uplink', 'True', 'vlanid']]
Ansible will give you:
TASK [Test] * fatal: [host]: FAILED! => {“ansible_facts”: {“discovered_interpreter_python”: “/usr/bin/python”}, “changed”: false, “msg”: “show_uplink is True but all of the following are missing: v, l, a, n, i, d“}
You can also find a library that will do this for you.
As an alternative, you can use subprocess, a native library, and run ansible as any other command:
import subprocess
cmd = ["ansible-playbook", "-i", "inventory.ini", "playbook.yml"]
process = subprocess.Popen(cmd,stdout=subprocess.PIPE)
while True:
output = str(process.stdout.readline(), encoding="utf-8")
if process.poll() is not None:
break
else:
print(output)
In this case the idea is to print line by line from python. But it can be modified to any other application.
Omitting the basics of what each of these objects means (plenty of information in the web), will compile some tricks to go beyond simple layouts with tkinter.
Layout management
You cannot mixed different managers in the same container. You’ll get the famous error
_tkinter.TclError: cannot use geometry manager grid inside . which already has slaves managed by pack
If the GUI you are creating requires a combination of these (e.g. displaying dataframes), the solution is using containers such as frames or canvas. Use pack to organize the containers inside the same window and then use grid (or any other) inside each container:
If you need scrolling for viewing multiple objects, a frame won’t work as it doesn’t support scrolling. One of the alternatives is to use the object canvas and insert a frame with the widgets you want on it:
Notice how the scroll region does not accurately match the position of the inner widgets. To get actual box size of the canvas, the canvas method bbox can be used. However remember to always update the canvas, otherwise you will get the size of the canvas when it was created: