ansible

Ansible evaluate list of tab separated strings

Ansible evaluate list of tab separated strings I am running a command, after which stdout is captured in a variable. The command output lists values separated by tabs. So I have something like var.stdout_lines: [ "a1tb1tc1", "a2tb2tc2", "a3tb3tc3" ] For further processing I’d like to split these lines into lists such as [ [a1, b1, …

Total answers: 1

using tabs within block for ansible blockinfile module

using tabs within block for ansible blockinfile module I want to output some text with tab as separator using ansible here’s task snippet – name: Create output file blockinfile: block: | Some texttmore text path: ‘{{ playbook_dir }}/output.txt’ create: true CURRENT OUTPUT # BEGIN ANSIBLE MANAGED BLOCK Some texttmore text # END ANSIBLE MANAGED BLOCK …

Total answers: 1

issue with ssh into lxd container using ansible

issue with ssh into lxd container using ansible I have created a dynamic inventory which fetch the created lxd containers (so that I don have to type the name of container each time) so here is the dynamic inventory plugin: community.general.lxd url: unix:/var/snap/lxd/common/lxd/unix.socket state: RUNNING here is the output of the inventory ansible-inventory -i lxd.yaml …

Total answers: 1

Edit configuration files idempotently

Edit configuration files idempotently When editing configuration files, such as /etc/sysctl.conf for example, it is often useful to do the update in an idempotent way, meaning that if the script is executed multiple times, you don’t end up with multiple entries for the configuration change you made. As a real-world instance where I encountered this, …

Total answers: 2

Ubuntu Server 22.04: How to write the Ansible debconf values into Postfix configuration?

Ubuntu Server 22.04: How to write the Ansible debconf values into Postfix configuration? I’m trying to automate the Postfix deployment into multiple Ubuntu servers: # lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy The Ansible tasks have the expected outcome, but for some reason the …

Total answers: 1

R Packages won't install via ansible (ALMA Linux 8)

R Packages won't install via ansible (ALMA Linux 8) Problem I would like to use ansible to provision a virtual box. This box will need to do multiple things, but it needs to have R installed as well as some specific packages that aren’t included in base R. I use the vagrant file provided below …

Total answers: 1

Systemd: provide password noninteractively to homectl

Systemd: provide password noninteractively to homectl I would like to activate a systemd-homed home via ansible, how can I provide the password to the systemd password agent programmatically? It seems that I cannot simply pipe the password to homectl activate directly… $ echo $PASSWORD | homectl activate $USER Broadcast message from root@…: Password entry required …

Total answers: 2

ansible conditional issues

ansible conditional issues this playbook gets total RAM, and based on that sets two variables, say A & B A is 40% of total RAM B is 60% of total RAM task is, if A greater than or equal to 32, then A must be 32, but if is less than 32, then keep A …

Total answers: 1

Does ansible actually use 'include' as keyword?

Does ansible actually use 'include' as keyword? I inherited a playbook like file thing.yaml with the following content: — – include: one.yaml – include: two.yaml I usually launch the yaml files with ansible-playbook as I can do with one.yaml and two.yaml, but thing.yaml is rejected with: ERROR! ‘include’ is not a valid attribute for a …

Total answers: 2

Turn off 'gather_facts' from 'ansible.cfg' or inventory file

Turn off 'gather_facts' from 'ansible.cfg' or inventory file Is there a way to turn off gather_facts other than at a play level? If I wanted to disable it permanently, is there a way to do it in the ansible.cfg or inventory file? Asked By: ImACarrot || Source From ansible.cfg: # plays will gather facts by …

Total answers: 2

ansible comparing all files in 2 directories and printing the difference

ansible comparing all files in 2 directories and printing the difference I have 2 directories $ tree dir{1..2} dir1 ├── file1 └── file2 dir2 ├── file1 └── file2 I want to compare all files in dir1 with all files in dir2 using ansible and print differences like this output: ${file1} from ${dir1}: diff content ${file1} …

Total answers: 1

Ansible: How to update array key value matching another directory key

Ansible: How to update array key value matching another directory key I have the following dictionaries: question: first_run: app: – answer: null name: first_name question: What is your First name? – answer: null name: last_name question: What is your Last name? core: – question: question1 – question: question2 answer: first_name: John last_name: Smith I use …

Total answers: 1

ansible select from dict

ansible select from dict need select from dict variables – name: test hosts: localhost vars: bum: 0 alpha: – 0 beta: – 0 – 1 test_vars: ‘{% if bum == 1 %}{{ alpha }}{% else %}{{ beta }}{% endif %}’ servers: – 127.0.0.1 – 127.0.0.2 tasks: – debug: msg: "This is {{ item }}" loop: …

Total answers: 1

ansible mysqldb not accepting item in tagrget options

ansible mysqldb not accepting item in tagrget options I have a db host, on which some sql files are present. I want to source it into db using an ansible playbook. so I find all files & register in variable, then try to source those using below code. – name: get schema files find: paths: …

Total answers: 1

Why Ansible failed to ping instance which I can connect?

Why Ansible failed to ping instance which I can connect? I can connect my AWS EC2 instance ssh -i "pizdform.pem" ec2-user@ec2-52-206-23-6.compute-1.amazonaws.com Last login: Tue Feb 21 12:36:50 2023 from … I tried Ansible ping cat test-project/hosts.ini [web] 52.206.23.6 ansible -i test-project/hosts.ini web -m ping -u ec2-user got failed ping 52.206.23.6 | UNREACHABLE! => { "changed": …

Total answers: 2

ansible copy ssh keys to multiple users' home directory

ansible copy ssh keys to multiple users' home directory I have ssh keypair on my ansible_host, which I want to copy to multiple user’s authorized keys on target host. I’m trying with-item construct, but it complaints about .pub key not an invalid key here’s what I’m trying. – authorized_key: user: "{{ item.user }}" key: "{{ …

Total answers: 2

docker logs err:"+ sudo -E kolla_set_configs sudo: unknown uid 42401: who are you?" in openstack container

docker logs err:"+ sudo -E kolla_set_configs sudo: unknown uid 42401: who are you?" in openstack container Multinodes(3 nodes) openstack cluster deploy by kolla-ansible, two nodes(2nd and 3rd nodes) are working well, the one node(1st_node) have some containers always Restarting with the error logs, e.g. kolla_toolbox container: + sudo -E kolla_set_configs sudo: unknown uid 42401: who …

Total answers: 1

Awk command with &&

Awk command with && What I am trying to do is to use the awk with Ansible so that I can get the hostname and the vlume that are greater than 50% I then can run the following to get the volume that has more than 50% ansible-playbook pb-servermgmt_runcommand_goce.yml –extra-vars "hostlist=test01 command=’df -hlT -x tmpfs …

Total answers: 1

Ansible: Firewalld how to set multiple services (loop from another playbook)

Ansible: Firewalld how to set multiple services (loop from another playbook) I see the issue when I try to set multiple services to the zone. Only first one is set and another always comes with the following error: TASK [Set services] ******************************************************************************************************************************************************************************************************************************* changed: [localhost] => (item=ssh) failed: [localhost] (item= samba) => {"ansible_loop_var": "item", "changed": false, …

Total answers: 1