ansible

Ansible nested loops through inventories plus outer loop of a list

空扰寡人 提交于 2019-12-24 15:09:47
问题 Suppose I have the following playbook: --- - hosts: all gather_facts: False vars: group: 'dev' tasks: - name: Just loop through a group and group_vars debug: msg: 'group is {{group}} target is {{item.0}} port is {{item.1}}' loop: > {{ groups[group] | product(hostvars[groups[group][0]]["ports"]) | list }} How can I change the loop part in case I have the variable named "group" defined as list and not as a single variable? For example: vars: group: - 'dev' - 'int' Thanks and regards. Stef 回答1:

Ansible Ignore_Unreachable is not working

无人久伴 提交于 2019-12-24 15:09:38
问题 Hoppy holidays all, I am trying to create a job that runs a yum command on all of my servers in an environment. That part is complete however I am looking to make the job continue running even if I run into UNREACHABLE errors. Here is my task: - name: "remove {{ service_to_uninstall_name }} packages" yum: name: "{{ service_to_uninstall_name }}" state: absent ignore_unreachable: true ignore_errors: true 来源: https://stackoverflow.com/questions/53961158/ansible-ignore-unreachable-is-not-working

How to let Ansible to skip run tasks on a host when its already configured?

佐手、 提交于 2019-12-24 13:04:08
问题 We have 2 playbooks Basic-env and Upgrade-env to manager our hosts. The ansible-playbook Basic-env is doing the the basic environment setup(yum, generate keys, security tasks) and register the services. The ansible-playbook Upgrade-env is doing the non-disruptive Upgrade(NDU) for the software and configuration. We will dynamic put new hosts into inventory, and run Basic-env each 10 mins. Question : Is possible to let ansible skip execute the tasks which in Basic-env at old hosts and only run

How to run an ansible playbook on a specific vagrant host

最后都变了- 提交于 2019-12-24 11:09:59
问题 I have a Vagrantfile which creates 3 servers. I have two ansible playbooks. playbook1 should be executed on every server first. The second playbook2 should only be executed on server1 and not on server2 and server3. How can I manage this with my Vagrantfile? Vagrant.configure("2") do |config| config.vm.box = "ubuntu/bionic64" config.vm.define "server1" do |server1| // end config.vm.define "server2" do |server2| // end config.vm.define "server3" do |server3| // end config.vm.provision "ansible

how to set ansible_config variables from user defined ansible.cfg

谁说我不能喝 提交于 2019-12-24 10:46:10
问题 I have a directory structure under which I am keeping my playbooks like follow: /home/monk/ |_____Ansible_work |_____[ansible.cfg] |_____[playbook_dir_1] | |_______playbook_1.yml |_____[playbook_dir_2] | |_______playbook_2.yml |_____[playbook_dir_3] | |_______playbook_3.yml |_____[playbook_dir_4] | |_______playbook_4.yml |_____[inventory] |___[inventory_1] |___[inventory_2] I am currently executing my playbooks like below from ansible_work dir: ansible-playbook -i inventory/inventory_1

大别阿郎IT英汉词典(长期更新)

可紊 提交于 2019-12-24 10:03:42
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 有不少英语IT词语,直译成中文后,往往让人摸不着头脑,让人误解;或者明明是一个很重要的概念,却因翻译平凡得没有任何特征,让人无法重视它;还有一些翻译,特别笨拙无趣,让人体会不到汉语的优美。 摸不着头脑:Object-Oriented,原译:面向对象。建议改作:面向物件(来自:编程) 平凡至极的:tuning profile,原译:优化文件。建议改作:优化配置表(来自:红帽RHCE8培训教材) 一个精心翻译过来的词,如果让人产生正确的联想,或者引起人的注意力,就是一个好的翻译。于是,我在这里收录我在工作、学习中遇到的、需要另类翻译的词条,供大家参考。如果您有异议,或者有更好的翻译,欢迎留言指教。 guest,宾客(虚拟化)| 原译:客户 >>>>> 为何译为“东家机”和“宾客机” handler task,旱獭任务 (Ansible)| 原译:无 >>>>>意义或解释 host,东家(虚拟化)| 原译:宿主 >>>>> 为何译为“东家机”和“宾客机” sparse file,海绵文件 (文件系统) | 原译:稀疏文件 >>>>> Sparse file译为“海绵文件”如何? 来源: oschina 链接: https://my.oschina.net/u/589241/blog/3146498

Unable to open shell: Ansible v2.3.1.0

非 Y 不嫁゛ 提交于 2019-12-24 10:03:24
问题 So I use Ansible day-to-day to manage our AWS instances and now I'm testing out managing our network infrastructure (I'm a Network guy, who can do some system admin stuff) but have run into a problem that I can't seem to get around. I have a Cisco 3750G here that I've enabled SSH on. I can ssh in with the specified user and run all the commands that are failing in my playbook. I'm able to use the ping module successfully from Ansible to this switch but whenever I try to use the ios_commands

Convert list of objects (string, string) into Dictionary (string, list<string>) in Ansible

删除回忆录丶 提交于 2019-12-24 10:02:17
问题 I have a list of objects (each object contains two attributes of type string) which I need to convert into Dictionary. The first attribute of the object will become a key, the second attribute of the object would have to be combined into a list of strings. I went through several solutions but couldn't find exactly what I need. Input Example: [ { "name": "AAA", "value": "111" }, { "name": "AAA", "value": "222" }, { "name": "BBB", "value": "333" }, { "name": "BBB", "value": "444" }, { "name":

filter a list of objects with ipaddr in Ansible

夙愿已清 提交于 2019-12-24 08:59:27
问题 If I had a list of ip addresses in Ansible, I could use the ipaddr filter to it and only get the passing values back: - debug: msg: "{{ ['127.0.0.1', 'foo', '2001:db8:32c:faad::'] | ipaddr('address') }}" Unfortunately I am working with a list of objects ( hostvars of group members to be precise). I want to do some tests on the list and only keeping the entries passing - but as objects. When reading the Jinja docs I stumbled across selectattr . Unfortunately it seems that ipaddr isn't a test,

Docker login to GCE using ansible 'Docker login' and _json_key

血红的双手。 提交于 2019-12-24 07:38:12
问题 I'm trying to write an ansible role that first does a docker login to a GCE instance before pulling images from the container registry. I need to do this because of the problem mentioned here. First I tried the code block below - name: Docker Login docker_login: registry: https://eu.gcr.io username: _json_key debug: true password: "{{ lookup('file', 'pulse-psg-863d9955d8a1.json')}}" The error I get with this is (private key modified) fatal: [en1-a-sftp-delivery-0]: FAILED! => { "changed":