ansible

JMESPath expression to flatten array of objects, each with nested arrays of objects

∥☆過路亽.° 提交于 2020-12-10 09:27:02
问题 I have JSON containing an array of databases, each database has an array of users, e.g. {"databases": [ {"db": "db_a", "users": [{"name": "alice"}, {"name": "alex"}]}, {"db": "db_b", "users": [{"name": "bob"}, {"name": "brienne"}]} ]} I would like to produce a flat array of databases and users, i.e. [ {"db": "db_a", "name": "alice"}, {"db": "db_a", "name": "alex"}, {"db": "db_b", "name": "bob"}, {"db": "db_b", "name": "brienne"} ] In SQL terms this would be a cartesian join or cartesian

Installing ceph using kolla-ansible for all-in-one setup

╄→尐↘猪︶ㄣ 提交于 2020-12-07 07:15:09
问题 I am trying to deploy the all-in-one configuration using kolla-ansible with ceph enabled enable_ceph: "yes" #enable_ceph_mds: "no" enable_ceph_rgw: "yes" #enable_ceph_nfs: "no" enable_ceph_dashboard: "{{ enable_ceph | bool }}" #enable_chrony: "yes" enable_cinder: "yes" enable_cinder_backup: "yes" glance_backend_ceph: "yes" gnocchi_backend_storage: "{{ 'ceph' if enable_ceph|bool else 'file' }}" cinder_backend_ceph: "{{ enable_ceph }}" cinder_backup_driver: "ceph" nova_backend_ceph: "{{ enable

平庸开发者的生存指南

旧街凉风 提交于 2020-12-06 18:31:56
我个人认识一些非常有才华的开发人员,他们可以一帆风顺地创建极好的软件。正是这些天赋人士,使得外行人对我们这个行业充满了很高的期望。但我要说的一个可悲的事实是: 并非每个人都是忍者/大师/明星开发者 。 我就不是这些闪耀的新星,我只是一名平庸的开发者。 如果你也不是天才玩家,那么本文将指导你如何在这个行业中生存下去。 最简单的事情——只要google一下 我记不了很多东西。像标准库中的函数和方法、参数位置、软件包名称,样板代码等等,都在我脑容量之外。 所以,我必须使用google搜索。我每天都这样做。我也一直在重复使用旧项目的代码。有时我甚至从StackOverflow或Github复制粘贴答案。是的,我的开发其实可称之为: StackOverflow驱动开发 。 但我并不孤单。许多其他开发人员也这样做。有一个受众面很广的twitter讨论就是由Ruby on Rails的创建者所启动的。 那么,为什么一开始会认为这种行径是不好的呢?因为它有若干缺点: 会导致你复制到糟糕的设计决策或易受其他人攻击的代码 会形成一种依赖心态:要是我们不能google到内容,那么只能向人求助 没有网就不能工作 但是,我不认为这些是大问题。它甚至可以作为是你的秘密武器。我有一些建议可用于减少其负面影响。 生存指南: 使用IDE来获得自动完成和建议,所以你不必google编程语言的基础内容;

Why Azure Cloud Shell is creating resource group in default subscription?

我与影子孤独终老i 提交于 2020-12-06 12:59:21
问题 I changed the subscription of the current session in Azure Cloud Shell to a different subscription using Set-AzContext as follows. But when I create a Resource Group using Ansible playbook in the same session of Azure Cloud Shell, the resource group is still created in default subscription, why? Set-AzContext -SubscriptionId "myOtherSubscription" Above command successfully changed the subscription from default to myOtherSubscription and showed the result as follows: Name Account

Concatenate strings using with_items and assign to a variable in Ansible

房东的猫 提交于 2020-12-06 12:31:06
问题 I need to save two 2 IPs to a variable in a vars_file when launching ec2_instances, which are used later during deployment. This is how I am saving a single server ip: - name: Save server public IP to vars file lineinfile: line="server_public_ip{{':'}} {{ item.public_ip }}" dest="{{ansible_env.HOME}}/dynamic_ips_{{ec2_environment}}" with_items: server.instances #server is registered in previous task The output I have in dynamic_ips file is server_public_ip: xxx.xxx.xx.x Now I have 2 servers

Can ansible variables be used to declare hosts in a playbook?

ぃ、小莉子 提交于 2020-12-06 03:43:48
问题 I have a playbook in the format below: --- - hosts: myIP tasks: - name: Install a yum package in Ansible example yum: name: ThePackageIWantToInstall state: present where myIP and ThePackageIWantToInstall are variables. When the job template runs, I would like the user in the extra variables popup to be able to go with: myIP = 192.168.1.1 ThePackageIWantToInstall = nano As the documentation doesn't provide an example of supplying a variable via a job template, is this possible? 回答1: Yes. -

Can ansible variables be used to declare hosts in a playbook?

被刻印的时光 ゝ 提交于 2020-12-06 03:40:29
问题 I have a playbook in the format below: --- - hosts: myIP tasks: - name: Install a yum package in Ansible example yum: name: ThePackageIWantToInstall state: present where myIP and ThePackageIWantToInstall are variables. When the job template runs, I would like the user in the extra variables popup to be able to go with: myIP = 192.168.1.1 ThePackageIWantToInstall = nano As the documentation doesn't provide an example of supplying a variable via a job template, is this possible? 回答1: Yes. -

Can ansible variables be used to declare hosts in a playbook?

做~自己de王妃 提交于 2020-12-06 03:40:17
问题 I have a playbook in the format below: --- - hosts: myIP tasks: - name: Install a yum package in Ansible example yum: name: ThePackageIWantToInstall state: present where myIP and ThePackageIWantToInstall are variables. When the job template runs, I would like the user in the extra variables popup to be able to go with: myIP = 192.168.1.1 ThePackageIWantToInstall = nano As the documentation doesn't provide an example of supplying a variable via a job template, is this possible? 回答1: Yes. -

How can I get a list of child groups in Ansible?

£可爱£侵袭症+ 提交于 2020-12-05 09:54:59
问题 I have an inventory file that looks like this: [master] host01 [nl] host02 [us] host03 [satellites:children] nl us How can I get a list of groups that have satellites as their parent? I am looking for a solution that works similar to this: - debug: msg="{{ item }}" with_items: "{{ groups['satellites:children'] }}" Update: The only solution I was able to come with is this: - debug: {{ item }} with_items: "{{ groups }}" when: item != "master" and item != "satellites" and item != "all" and item

Ansible 1.9.4 : Failed to lock apt for exclusive operation

旧城冷巷雨未停 提交于 2020-12-02 03:38:57
问题 I bumped into Failed to lock apt for exclusive operation issue: https://github.com/geerlingguy/ansible-role-apache/issues/50 I posted a lot of details in GitHub. I googled a lot of "Failed to lock apt for exclusive operation" Ansible complaints, but no simple answer. Any help? 回答1: I'm also getting this error, while setting up a couple of new boxes. I'm connecting as root , so I didn't think it was necessary, but it is: become: yes Now everything works as intended. 回答2: I know this question