[ansible-project] Re: ansible-core 2.14 and determining if top level variables exist in source

2023-02-01 Thread flowerysong
On Wednesday, February 1, 2023 at 2:42:33 PM UTC-5 noke...@gmail.com wrote: Hi, I just opened https://github.com/ansible/ansible/issues/79874 and Matt explained that 2.14 change is working as designed and closed the issue. Matt put a link in the issue describing variable lazy eval and how

[ansible-project] Re: ansible.builtin.service hangs

2022-10-13 Thread flowerysong
On Thursday, October 13, 2022 at 6:37:05 AM UTC-4 uto...@gmail.com wrote: > Your last "when:" is wrong. > > when: 'not i_am_master' > > A quoted when condition that contains no jinja mustaches is just a string, > which is always true. You want > > when: not i_am_master > You are

Re: [ansible-project] nested roles

2022-06-18 Thread flowerysong
I highly disagree with this, and would be interested in a pointer to the documentation that you say claims "importing a role in the tasks of another role is a bad idea" since I've never seen that in the official Ansible documentation. Explicitly importing or including the role provides more

[ansible-project] Re: Add/substract to list items - but without a loop

2022-01-21 Thread flowerysong
This is a little weird because of the use of zip() to turn the list of integers into a list of lists, but still fairly readable IMO: foo | zip | map('sum', start=-1) On Friday, January 21, 2022 at 8:14:27 AM UTC-5 dick@geant.org wrote: > Hi > I have this list of ints: > > selection: > -

[ansible-project] Re: include_tasks and noop

2021-12-09 Thread flowerysong
I don't see any benefit to the proposed feature. If you want to skip an include based on a flag value, you can do that without adding complexity to the engine. - include_tasks: "{{ task_file }}.yml" when: task_file | default('noop') != 'noop' On Thursday, December 9, 2021 at 6:05:10 PM UTC-5

[ansible-project] Re: Ability for a host to declare which roles should be applied to it?

2021-12-08 Thread flowerysong
ver, I"m not actually using that role. > > My main question is if rendering 'import_role' task files follows best > practices or if there is an alternative to what I'm doing I'm not aware of. > > On Wednesday, December 8, 2021 at 12:06:52 PM UTC-6 flowerysong wrote: > >

[ansible-project] Re: Ability for a host to declare which roles should be applied to it?

2021-12-08 Thread flowerysong
Set `tags: always` on your include_role task, so that it always runs. On Wednesday, December 8, 2021 at 12:31:16 PM UTC-5 phi...@kauffman.me wrote: > I'd like to start a discussion on the ability to define roles to > `import_role` from within host_vars. Instead of *only* defining those roles

[ansible-project] Re: Combining several facts into one array

2021-10-05 Thread flowerysong
While the use of json_query obscures the actual structure that you're dealing with (and you haven't provided an example), this looks an awful lot like you're taking something where you already have all of the information you want in a list, and turning it into three lists. Is there a reason you

[ansible-project] Re: Excluding items from debug output

2021-10-05 Thread flowerysong
As the other reply pointed out you were comparing a string to a list, so it was always unequal. However, there's a much cleaner way to output the desired information (a task loop will still have output for skipped items): - name: Output filtered directory list debug: msg: "{{ user_list |

[ansible-project] Re: Simple Playbook for mysql query

2021-09-18 Thread flowerysong
2.9 is before the collection split, so the available version of the module is called simply `mysql_query`. Unless you have a specific reason to use the collection (and have correctly installed the collection locally), you should not use `community.mysql.mysql_query` with 2.9.x. On Friday,

[ansible-project] Re: "10" compares as older than "10.0" with version()

2021-09-14 Thread flowerysong
On Tuesday, September 14, 2021 at 7:20:59 PM UTC-4 Andy Smith wrote: > My ansible_distribution_version returns "10". This debug fires: > > - name: version 10 < 10.0 > ansible.builtin.debug: > msg: > - "I think 10 is older than 10.0" > when: {{ ansible_distribution_version }} is

Re: [ansible-project] Doubt

2021-08-26 Thread flowerysong
On Friday, August 27, 2021 at 12:37:39 AM UTC-4 ra...@linuxia.de wrote: > On 26/08/2021 21:26, Doug Hunley wrote: > > try > > *- hosts: all > > roles: > > - role: debian_stock_config > > when: ansible_facts['os_family']|lower == 'debian' > > That condition is overcomplicated. >

[ansible-project] Re: Gathering facts from hosts

2021-04-13 Thread flowerysong
On Tuesday, April 13, 2021 at 9:26:36 AM UTC-4 werner...@ufz.de wrote: > Hi list, > > I wonder if there is a dynamic way of providing facts about hosts. > > I only find the possibility to include facts that are hardcoded in one > file (or multiple), but they are static, and maybe outdated.

[ansible-project] Re: best practices for removing files in a dir when using Ansible

2021-02-25 Thread flowerysong
On Thursday, February 25, 2021 at 10:45:09 AM UTC-5 paneva wrote: > Hi Ansible wizards! > I am currently working on few tasks in a playbook that are going to > remove old files. There is a set number of files that I need to keep, say 3 > (most recent), and the rest should be removed. I am

Re: [ansible-project] Determine last host in host list

2021-01-18 Thread flowerysong
On Monday, January 18, 2021 at 5:13:09 PM UTC-5 vbo...@gmail.com wrote: > On Mon, 18 Jan 2021 22:11:35 +0100 > Vladimir Botka wrote: > > > On Mon, 18 Jan 2021 11:32:05 -0800 (PST) > > "'Mark Tovey' via Ansible Project" > > wrote: > > > > > I need to determine how many hosts are left to be

[ansible-project] Re: Using formatted PS JSON in play.

2020-11-06 Thread flowerysong
On Thursday, November 5, 2020 at 5:16:20 PM UTC-5, jesse...@gmail.com wrote: > > So i'm having difficulties and am quite stuck... > > My goal is to capture details from a UNC paths NTFS ACLS. > > - name: process fish > set_fact: > chum: "{{ fishing.stdout | from_json }}" > > - name:

Re: [ansible-project] NameError: global name 'fw offline' is not defined

2020-07-09 Thread flowerysong
On Thursday, July 9, 2020 at 12:26:34 PM UTC-4 keith.no...@sjsu.edu wrote: > I saw this, however this issue was posed and fixed back in 2018. I'm using > a current version of Ansible. I can dig into the python script however from > the comments I'm not clear on what would need to be done? >

Re: [ansible-project] Re: Issue trying to parse tag

2019-12-08 Thread flowerysong
On Monday, December 9, 2019 at 1:17:26 AM UTC-5, Christian Del Pino wrote: So what is the best way to get the details of a new instance using tags, or > is another method recommended? > ...use the correct set of inventories with your playbook? -- You received this message because you are

[ansible-project] Re: Issue trying to parse tag

2019-12-06 Thread flowerysong
On Friday, December 6, 2019 at 2:21:06 PM UTC-5, Christian Del Pino wrote: > > > I am currently trying to connect to a newly created ec2 instance via a tag > that I created, but I am getting an error during the run: > > setting up inventory plugins > Parsed >

Re: [ansible-project] using set_fact with until

2019-09-11 Thread flowerysong
On Wednesday, September 11, 2019 at 3:57:30 PM UTC-4, Vladimir Botka wrote: > > On Wed, 11 Sep 2019 18:02:08 +0530 > Kamesh Sampath > wrote: > > > > >> set_fact: > > > >> che_keycloak: > > > >> "{{ lookup('k8s', > > > >>

[ansible-project] Re: How to check when at least one element of a list is not null

2019-06-26 Thread flowerysong
On Wednesday, June 26, 2019 at 10:08:17 AM UTC-4, jean-christophe manciot wrote: > > The real goal here is to perform an action only when at least one of > *inventory_hostname* groups from *group_names* matches one group from > another list of groups (in this example: ```git|local|ntopng```) .

[ansible-project] Re: Convert a hex number to decimal

2019-05-24 Thread flowerysong
On Friday, May 24, 2019 at 3:25:06 PM UTC-4, Bob Carroll wrote: > > This has to be easy, but I have tried a way to many things. Given a hex > number as a string, say '8d', I cannot convert it to a decimal string. > I presumed to prepend '0x' but '{{ "0x8d" | int }}' returns 0. I am not >

[ansible-project] Re: Q on hostvars access to inventory variables ad-hoc vs playbook

2019-05-15 Thread flowerysong
On Wednesday, May 15, 2019 at 2:52:26 PM UTC-4, J Davis wrote: > > $ ansible-playbook -i prtmpftp, hostvarstest.yml > You told ansible-playbook to use 'prtmpftp,' as the inventory source; this does not include any host vars, since it's a simple comma-separated list of hostnames. You should

[ansible-project] Re: Ansible vault -- "ERROR! playbooks must be a list of plays"

2019-01-17 Thread flowerysong
On Thursday, January 17, 2019 at 11:35:12 AM UTC-5, John Harmon wrote: > > > I wouldn't be surprised if I am using this incorrectly, but I could use > some outside input. Consider the following tree (not in a role): > . > ├── get_user_info.yml > └── vault.yml > > > *Q1: I had to use vars_files

[ansible-project] Re: Removing empty strings from a list

2018-12-18 Thread flowerysong
On Tuesday, December 18, 2018 at 2:47:30 AM UTC-5, Karl Auer wrote: > > I am trying to build a list of names from a list of objects. It works > fine, but some of the objects don't have a name. No problem, I use the > default() filter to set those elements of my list to empty strings, like >

[ansible-project] Re: Creating an aws target group with ansible

2018-11-28 Thread flowerysong
On Wednesday, November 28, 2018 at 11:16:58 PM UTC-5, joeldamata wrote: > What Im trying to accomplish is to create a network load balancer target > group from dynamically generated list of instances. > > brokerInstancesList is a list of instance ids. I need to iterate over this > list and add

Re: [ansible-project] Re: Complex host patterns

2018-10-23 Thread flowerysong
On Tuesday, October 23, 2018 at 8:25:12 PM UTC-4, Gonzalo Servat wrote: > > On Wed, Oct 24, 2018 at 2:29 AM flowerysong > wrote: > >> On Tuesday, October 23, 2018 at 2:24:59 AM UTC-4, Gonzalo Servat wrote: >>> >>> Hi All >>> >>> When wor

[ansible-project] Re: Complex host patterns

2018-10-23 Thread flowerysong
On Tuesday, October 23, 2018 at 2:24:59 AM UTC-4, Gonzalo Servat wrote: > > Hi All > > When working with host patterns > , is > it possible to craft one that says "must be in group X *and* must be in > either group Y, W and

[ansible-project] Re: AWS_EC2 plugin keyed_groups suffix option

2018-10-15 Thread flowerysong
On Monday, October 15, 2018 at 7:45:15 PM UTC-4, Guy Knights wrote: > > Is there any way to specify a suffix for the keyed_groups option in the > aws_ec2 inventory plugin? I'm looking at migrating from Ansible 2.4 to 2.6 > and would like to switch from the old ec2 dynamic inventory script. >

[ansible-project] Re: Automate a command which requires random keystrokes

2018-08-29 Thread flowerysong
On Wednesday, August 29, 2018 at 6:52:47 PM UTC-4, Bharath Kumar wrote: > > Hello All, > > I have a command that has to be automated/written into playbook that > requires 15-20 random keystrokes. > > The scenario is; I am using certutil to generate a key. > > The certutil command when run

Re: [ansible-project] Comparing part of a string as an integer

2018-08-23 Thread flowerysong
On Thursday, August 23, 2018 at 3:14:27 PM UTC-4, Jameson Pugh wrote: > > On Thu, Aug 23, 2018 at 2:26 PM flowerysong > wrote: > >> On Thursday, August 23, 2018 at 1:23:23 PM UTC-4, Jameson Pugh wrote: >>> >>> I apologize, guys. There were some typeos in my

Re: [ansible-project] Comparing part of a string as an integer

2018-08-23 Thread flowerysong
On Thursday, August 23, 2018 at 1:23:23 PM UTC-4, Jameson Pugh wrote: > > I apologize, guys. There were some typeos in my example. This isn't the > actual code I'm using because I tried to simplify the example to only > include the problem I'm having. This is a copy of the playbook that >

[ansible-project] Re: AWS instance profile - how to create in Ansible?

2018-05-11 Thread flowerysong
On Friday, May 11, 2018 at 9:06:08 PM UTC-4, Karl Auer wrote: > > I can't figure out how to create an instance profile. > > It's easy enough to attach an instance profile; the ec2_lc module has an > instance_profile_name parameter. > > But how to create the policy and role? > > There seem to be

[ansible-project] Re: issue with ansible dry-run mode (--check) on package installation tasks (yum and apt modules)

2018-05-09 Thread flowerysong
On Thursday, May 10, 2018 at 12:11:02 AM UTC-4, js.a wrote: > > Hello guys. > > I'm here to bring an issue with Ansible dry-run (--check) mode. I have > been facing a curious situation where package installation made using > Playbooks and run in a dry-run mode is not working as expected. Using

[ansible-project] Re: ALB module coming soon?

2018-05-09 Thread flowerysong
On Wednesday, May 9, 2018 at 11:14:27 AM UTC-4, Karl Auer wrote: > > Does anyone know if an AWS application load balancer module is coming > soon? I've seen a few requests for one when googling, but no indication of > a new module. > "Coming soon" as in came out eight months ago:

Re: [ansible-project] Re: how to filter with variables instead of literals in ec2_instance_facts?

2018-05-06 Thread flowerysong
On Sunday, May 6, 2018 at 10:38:14 AM UTC-4, Karl Auer wrote: > > How does "~" differ from "+"? > > > "{{ 'hello' ~ name ~ 'there!' }}" > vs > "{{ 'hello' + name + 'there!' }}" > > ? > Since this is an incredibly common question, I've written up a short explanation with examples:

Re: [ansible-project] Re: how to filter with variables instead of literals in ec2_instance_facts?

2018-05-05 Thread flowerysong
On Saturday, May 5, 2018 at 7:54:27 PM UTC-4, Karl Auer wrote: > > > Did you actually try that? > > When I use that, I get the same error as before: An error occurred > (InvalidParameterValue) when calling the DescribeInstances operation: The > filter 'GroupName' is invalid > > ("GroupName" is

[ansible-project] Re: how to filter with variables instead of literals in ec2_instance_facts?

2018-05-05 Thread flowerysong
On Saturday, May 5, 2018 at 6:57:33 PM UTC-4, Karl Auer wrote: > > I've tried a LOT of things now, and have come to the conclusion that > ec2_instance_facts requires a literal filter name, at least in the case > of "tags:Name". > > This makes that filter essentially useless :-( > > Please, can

[ansible-project] Re: map()...What am I doing wrong here?

2018-04-22 Thread flowerysong
On Sunday, April 22, 2018 at 7:30:15 PM UTC-4, Gregory Mirsky wrote: > > I've been trying to extract the values for subnet_id from the dictionary > subnet_facts but keep getting undefined (3 times instead of the values) as > a return value. I should be getting [subnet-fd6bfa95,

[ansible-project] Re: Hostnames with EC2 inventory plugin

2018-04-11 Thread flowerysong
On Wednesday, April 11, 2018 at 3:19:51 AM UTC-4, os...@apartum.com wrote: > > I'm testing the new Amazon EC2 dynamic inventory plugin. I need to set the > host names to the "Name" tag, but I don't understand the documentation. > Reading this: >

[ansible-project] Re: Find module results not returning as expected

2018-04-07 Thread flowerysong
On Saturday, April 7, 2018 at 8:50:44 AM UTC-4, Gabriel Forster wrote: > > Using the find module to find unknown files in a given directory and > register the results as a variable to be looped through later on. The debug > of the registered var shows a full on array of all kinds of attributes

[ansible-project] Re: Remove missing files from a list

2018-04-04 Thread flowerysong
d preserve the ordering in the generated file instead of splitting it into two lists, so that someone manually adding a file and uncommenting its line creates the same state as re-templating the file. So, something like this: https://gist.github.com/flowerysong/d6c5b16123473279c025fe8d34c20bd6 --

[ansible-project] Re: Depreciated `ask_sudo_pass` works while new-hotness `ask_become_pass` fails

2018-03-29 Thread flowerysong
On Thursday, March 29, 2018 at 7:52:44 PM UTC-4, Matthew Wyant wrote: > > I'm in the middle of migrating our Ansible projects to 2.5. Specifically, > moving to the new network_cli connection module. > > So far, everything is working well, except using the `become` framework. > The short of it

Re: [ansible-project] Re: Absurd run_once behavior, skipping entirely if first node fails a when test

2018-03-19 Thread flowerysong
On Monday, March 19, 2018 at 9:42:58 PM UTC-4, Josh Smift wrote: > > My use case involved roles. I had something like > > - hosts: web:app:db > roles: > - role: myrole > when: color == "blue" > > In the role, there was a task that ran on localhost (via delegate_to), but > only once

[ansible-project] Re: Absurd run_once behavior, skipping entirely if first node fails a when test

2018-03-19 Thread flowerysong
On Monday, March 19, 2018 at 2:49:12 PM UTC-4, Alex Hunt wrote: > > When running a task with run_once, if the first node is skipped, the > entire task is skipped, rather than running on the first host that is not > skipped. > > This behavior is not what is intuitively understood, this behavior

[ansible-project] Re: Repeat a task based on a csv string from extra_var

2018-03-18 Thread flowerysong
On Sunday, March 18, 2018 at 11:17:56 PM UTC-4, GoFigure wrote: > > Hello All, > > There is a specific nut I am trying to crack in ansible. We want to dev a > job template that add disks to and server instance. The size and number of > disk will be provided as an extra_var csv string, eg.

[ansible-project] Re: git checkout to new branch and change back to local user

2018-03-13 Thread flowerysong
are various ways to make it interactive. - hosts: localhost become: true tasks: - command: whoami become_method: su become_user: flowerysong vars: ansible_become_pass: "{{ user_passwords.flowerysong }}"

[ansible-project] Re: git checkout to new branch and change back to local user

2018-03-13 Thread flowerysong
On Tuesday, March 13, 2018 at 10:35:27 AM UTC-4, Patrick Hunt wrote: > > I can help to address #2 at least for now. >> > > Ansible does not allow you to chain "Become" statements. > This is true; you cannot use two types or levels of privilege escalation at once. > In other words you

[ansible-project] Re: Trying to capture value from with_lines loop

2018-03-04 Thread flowerysong
On Sunday, March 4, 2018 at 10:46:27 PM UTC-5, Evan wrote: > > I'm trying to loop through a list (file) of powervc regions, delegating a > command to them, and if that command (find a vm) is successful (ie: the vm > is on that region) I want to record the region name. I'm using delegate_to >

[ansible-project] Re: Can I combine with_items and when?

2018-02-26 Thread flowerysong
On Monday, February 26, 2018 at 9:39:10 AM UTC-5, Nico Sabbi wrote: > > HI, > can I combine when: and with_items clauses as in this example? > > become: true > become_user: root > tasks: > - block: > - debug: > msg: "riga {{item}}" > - user: > name: "{{

Re: [ansible-project] Run pre/post tasks once with serial 1

2018-02-15 Thread flowerysong
On Thursday, February 15, 2018 at 12:51:23 PM UTC-5, Michael Perzel wrote: > > Gah not quite there. I use meta_end play when I calculate that a patch > isn't relevant so that we don't spend time decomissioning a host that > doesn't need a patch. Problem is this skips the post_tasks if the last

[ansible-project] Re: Yaml statement over multiple lines.

2018-02-13 Thread flowerysong
On Tuesday, February 13, 2018 at 7:25:24 AM UTC-5, mail.ph...@gmail.com wrote: > > > How should I split this dest: statement into multiple lines ? > > - copy: > content: "{{ config.stdout[0] }}" > *dest: "{{ backup_root }}/{{ inventory_hostname }}/dhcp_leases_{{ >

[ansible-project] Re: Looping over nested inventory items with conditional

2018-02-13 Thread flowerysong
test'] OR inventory_hostname > in groups['dev']) | > ternary(hostvars[item[0]].ansible_host,hostvars[item[1]].ansible_host) }}" > I'm not entirely sure of your constraints, but it seems like you would want something more like https://gist.github.com/flowerysong/ae18f75d210