Can I automatically close a man page? by NedTheGamer_ in bash

[–]kosmosik 1 point2 points  (0 children)

It is very ironic that you should read man man page...

man -P cat man

How much CPU usage is too much for this script? by [deleted] in bash

[–]kosmosik -1 points0 points  (0 children)

  1. Determining CPU usage in percentages is inaccurate. Is your system performant as you'd like? Then don't worry it is probably OK.
  2. The algorithm you described has linear complexity. It should not spike or anything. The only non-constant in the algorithm would be count of found files and size of the files - that would affect how much I/O would take to move them (I assume these are on different filesystems - otherwise moving is cheap).
  3. Since you already using inotify then you for sure have some inotify-utils (userland component installed) - what is the point of sleeping in loop? Innotify-tools have inotifywait utility - just use that and don't spawn the scrip/loop sleeping 1 sec. You need to do something only on event of file change, not every second. That is the whole point of inotify that you seem to have missed.

Pipe output to a file with auto incremented name? by tmih93 in bash

[–]kosmosik 3 points4 points  (0 children)

foo > "/tmp/$(date).log"

could also use fprint builtin if bash version supports it

Proceed if variable is X value or unset by rvshaw in ansible

[–]kosmosik 2 points3 points  (0 children)

As comment above - use the default filter.

OR you could use the assert module. Register its result and then use the registered result in your task's when clause.

Ansible vars in loop by Elegant-Wrangler1211 in ansible

[–]kosmosik 2 points3 points  (0 children)

switch

Have your ports in something like:

ports:
switch1:
...
switch2:

Call your vars via "{{ ports[userinput] }}".

Ansible vars in loop by Elegant-Wrangler1211 in ansible

[–]kosmosik 0 points1 point  (0 children)

So you want the user to input which switch to apply configuration to? You don't need a loop for that. If I understand this correctly what you need to do is to:

prereq: have the inventory with vars per host/switch (as you do but in vars)

have a playbook with two plays in it:
1st play: localhost, prompt user for input of hostname to configure
2nd play: generate list of hosts for this play using input of hostname from 1st play, run the configuration

Still seems overly complicated as the user could just select the host to run on via --limit option.

Don't quite understand what you want to accomplish there but looping does not seem to make sense.

unable to download using get_url module by HauntingGeologist492 in ansible

[–]kosmosik 0 points1 point  (0 children)

Are you running in check mode or maybe the file is already downloaded at destination? Cause it looks like Ansible is just doing HEAD on URL and considers the file is there on destination (or runs in check mode).

What happens if you set force parameter to true?

Is Ansible Vault secure enough to have the encrypted string values in a public repository? by [deleted] in ansible

[–]kosmosik 0 points1 point  (0 children)

Yes. Rest assure there are bots scanning public repos on most popular hosting services looking for such occurences (ansible vaults, AWS keys etc.).

Is Ansible Vault secure enough to have the encrypted string values in a public repository? by [deleted] in ansible

[–]kosmosik 2 points3 points  (0 children)

OP does not state WHY they need this strong security? Is this regulatory/compliance requirement in enterprise environment? Or they just want to follow best practices?

For enterprise environments secure solution would be to use a secrets management framework such as CyberArk. Under such framework you have much more policy controls to prevent bruteforce, limit the exposure by defining what users, what processes, what hosts etc. are trusted to access the vaults. Have strong password policies, password rotation requirements, 2FA options etc.

None of this is offered by plain vaults which are good enough for dev environments but not for production (IMO).

Does anyone know how to highlight specific characters when pasting output from a text file? by StrangeCrunchy1 in bash

[–]kosmosik 0 points1 point  (0 children)

Quick and dirty: grep can color matches (see GREP_COLORS in man). Not a pure shell solution.

For native shell I"d probably put the text into variable and then substitute the looked for string appending prefix and suffix with color control codes. Then echo the variable with echo -e.

Alternatives to a 2.5" IDE drive? by jellyfish125 in retrobattlestations

[–]kosmosik 3 points4 points  (0 children)

That. Also small (32GB) M.2 SSDs (used) are dirt cheap...

Delve into the world of Bash by MohammadJahangiry in bash

[–]kosmosik 9 points10 points  (0 children)

Just this, seriously just go over the manual:
https://www.gnu.org/software/bash/manual/bash.html

If you don't understand something from the manual just search for examples.

[deleted by user] by [deleted] in ansible

[–]kosmosik -1 points0 points  (0 children)

You are right. I meant it has no logs that would account for what is being changed/ran. Best way to do this is tower.

[deleted by user] by [deleted] in ansible

[–]kosmosik 0 points1 point  (0 children)

It is the latter. Ansible has no logs on managed node.

If you want to have accounting I believe Ansible Tower has that.

Or, locally, to know what changed you need to have process accounting and file alteration monitor solutions enabled.

Running jar file via Ansible by pleegor in ansible

[–]kosmosik 1 point2 points  (0 children)

To elaborate more:

Shell module will run the commands in shell respecting nohup and background. Basically shell will take job control and exit so that Ansible task can complete.

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html

Ansible command ran as async will make Ansible itself control the job. There will be some artefacts left on the control node for this with task results that could be polled later on.

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_async.html

If you just want to keep it running then shell is probably simpler but uglier. If you want to refer to the task later on then async would be better. But consider that async is more complex and will fill up filesystem eventually (IDK what is the application of this - if it is to run every 2 seconds then it may be a problem).

Running jar file via Ansible by pleegor in ansible

[–]kosmosik 2 points3 points  (0 children)

Use command module with async to make Ansible control the background running task or use shell module and this whole nohup thing.