ansible

Ansible: Use of Diff command using Ansible

你说的曾经没有我的故事 提交于 2021-02-07 14:23:18
问题 I am trying to one simple task which is find out the difference between the two files and store it in notepad. I am not able to do it with command as well as shell. Please suggest where i am going wrong- --- - hosts: myserver tasks: - name: get the difference command: diff hosts.new hosts.mod register: diff - debug: var=diff.cmd Error - fatal: [zlp12037]: FAILED! => {"changed": true, "cmd": ["diff", "hosts.new", "hosts.mod"], "delta": "0:00:00.003102", "end": "2017-03-29 10:17:34.448063",

Ansible/Jinja2 how to append key into list of dict

蹲街弑〆低调 提交于 2021-02-07 09:13:03
问题 I would like to have dictionary defined in ansible like this vhosts: git_branch_1: - { a: example.com, customer: a } - { a: example.com, customer: b } - { a: example.org, customer: a } git_branch_2: - { a: example.com, customer: x } - { a: example.org, customer: y } Some tasks I need to loop only over dict keys, this works fine - name: "just debug" debug: msg={{ item }} with_items: "{{ vhosts.keys() }}" But some tasks I would like to iterate over list from each key, and append the key as

Ansible/Jinja2 how to append key into list of dict

▼魔方 西西 提交于 2021-02-07 09:12:28
问题 I would like to have dictionary defined in ansible like this vhosts: git_branch_1: - { a: example.com, customer: a } - { a: example.com, customer: b } - { a: example.org, customer: a } git_branch_2: - { a: example.com, customer: x } - { a: example.org, customer: y } Some tasks I need to loop only over dict keys, this works fine - name: "just debug" debug: msg={{ item }} with_items: "{{ vhosts.keys() }}" But some tasks I would like to iterate over list from each key, and append the key as

ansible 批量更新filebeat配置文件

流过昼夜 提交于 2021-02-06 15:38:08
一、filebeat准备工作: 1、prod-tomcat 为生产组,使用ansible -ping 可以通 2、生成filebeat配置文件 3、如果执行不成功 ,注意双引号单引号替换 二、下发替换配置文件 ansible prod-tomcat -S -R root -m copy -a 'src=/etc/ansible/file/filebeat.yml dest=/etc/elk/filebeat/filebeat.yml mode=600 owner=root group=root' 三、kill掉filebeat进程 ansible prod-tomcat -S -R root -m shell -a 'pkill filebeat' 四、后台启动filebeat进程 ansible task -m shell -a “chdir=/usr/local/filebeat nohup ./filebeat -e -c filebeat.yml > /dev/null 2>&1 &” 五、查看后台进程 ansible prod-tomcat -S -R root -m shell -a 'ps aux | grep filebeat | grep -v grep' 来源: oschina 链接: https://my.oschina.net/u/4321917/blog

Ansible provisioning ERROR! Using a SSH password instead of a key is not possible

醉酒当歌 提交于 2021-02-05 21:35:25
问题 I would like to provision with my three nodes from the last one by using Ansible. My host machine is Windows 10. My Vagrantfile looks like: Vagrant.configure("2") do |config| (1..3).each do |index| config.vm.define "node#{index}" do |node| node.vm.box = "ubuntu" node.vm.box = "../boxes/ubuntu_base.box" node.vm.network :private_network, ip: "192.168.10.#{10 + index}" if index == 3 node.vm.provision :setup, type: :ansible_local do |ansible| ansible.playbook = "playbook.yml" ansible.provisioning

Ansible provisioning ERROR! Using a SSH password instead of a key is not possible

天涯浪子 提交于 2021-02-05 21:35:09
问题 I would like to provision with my three nodes from the last one by using Ansible. My host machine is Windows 10. My Vagrantfile looks like: Vagrant.configure("2") do |config| (1..3).each do |index| config.vm.define "node#{index}" do |node| node.vm.box = "ubuntu" node.vm.box = "../boxes/ubuntu_base.box" node.vm.network :private_network, ip: "192.168.10.#{10 + index}" if index == 3 node.vm.provision :setup, type: :ansible_local do |ansible| ansible.playbook = "playbook.yml" ansible.provisioning

Why I cannot prompt for a variable that will be shared by multiple plays (ansible 1.6.5)

时光总嘲笑我的痴心妄想 提交于 2021-02-05 18:51:42
问题 I have distilled a playbook that has three plays. The goal is to collect the database password from a prompt in one play and then use the same password in the other two plays. --- - name: database password hosts: - webservers - dbservers vars_prompt: - name: "db_password" prompt: "Enter Database Password for databse user root" default: "root" - hosts: dbservers tasks: - command: echo {{db_password | mandatory }} - hosts: webservers tasks: - command: echo {{db_password | mandatory }} It fails

Why I cannot prompt for a variable that will be shared by multiple plays (ansible 1.6.5)

≡放荡痞女 提交于 2021-02-05 18:51:32
问题 I have distilled a playbook that has three plays. The goal is to collect the database password from a prompt in one play and then use the same password in the other two plays. --- - name: database password hosts: - webservers - dbservers vars_prompt: - name: "db_password" prompt: "Enter Database Password for databse user root" default: "root" - hosts: dbservers tasks: - command: echo {{db_password | mandatory }} - hosts: webservers tasks: - command: echo {{db_password | mandatory }} It fails

2021年的十五个DevOps趋势预测

白昼怎懂夜的黑 提交于 2021-02-05 09:21:09
DevOps已经走过了很长的一段路,毫无疑问,它将在今年继续闪耀。由于许多公司都在寻找围绕其数字化转型的最佳实践,因此了解领导者认为该行业的发展方向非常重要。从这个意义上说,下面的文章收集了DevOps高层对2021年DevOps趋势的回应。 让我们看看他们每一个人在未来一年对DevOps有什么看法。 1.迁移到微服务成为必选项。 “从单一服务到微服务和容器架构的转变对所有公司的数字化转型都是必须的。它不再是一个或多个选择。Kubernetes的应用将会越来越多,当组织采用多云时,Terraform将会是自动化基础设施的最终选择。”——威普罗DevOps首席工程师Sachidananda Pattnaik 2.混合模式将成为部署规范。 “2020年加速了远程工作,加快了向云的迁移,并将DevOps从最佳实践转变为每个业务的重要组成部分。随着我们进入2021年,该行业将在多个方面采用混合动力。首先,企业将充分采用混合劳动力,将远程工作和现场团队协作的优势结合起来。第二,商业模式将变得混合,例如将虚拟规模与本地网络相结合的会议。最后,混合动力将成为部署标准,因为公司将其堆栈现代化,以利用云本地技术,但意识到并非所有东西都能脱离prem。2021年的赢家将是在其业务、模型和产品中采用混合动力的公司。”—— 杰蛙科技开发者关系VP Stephen Chin 3.DataOps 将繁荣发展。

一文读懂云上DevOps能力体系

你说的曾经没有我的故事 提交于 2021-02-04 12:46:36
简介: 阿里云ECS自动化运维套件架构师,深度拆解云上运维能力体系建设:自动化运维等级金字塔、自动化运维的进阶模式、DevOps的基础核心、云上标准化部署三大能力…… 序言 云计算行业已经有十多年的发展了,话题早已从“要不要上云”转向“如何用好云”。“要不要”其实是一个决策性的话题,直到决策出来一个结果了,话题就算结束了。而“如何用好云”却是一个持续性的话题。 一般来说,在规划阶段开始,企业就会开始思考“如何用好云”,这个话题会伴随用云的整个过程。如果简单地从工作类型划分,除了业务代码的研发(Dev),其他的部分都可以称为运维(Ops),包含资源创建(环境部署)、应用部署、资源管理、资源监控、报警、故障排查等工作。 笔者从事云计算工作超过五年时间,参与开发过多款云产品,可以说既是云计算产品的消费者,也是云计算产品的生产者。在这里,笔者谈一谈对云上DevOps能力体系的多年思考和总结,希望对准备上云或是已经上云的运维人员有所帮助。 1 自动化运维等级金字塔 从运维自动化等级和程度来看,DevOps其实是一种非常高级的自动化,不仅自动化程度比较高,而且对于自动化的完成方式有着非常严格的定义。关于运维自动化与DevOps的关系,其实可以非常好地参考汽车自动驾驶技术分级标准,笔者做了个对比图,如图1。 图1:自动化运维等级金字塔 如图1,自动化运维可分为5个等级, 分别是手动运维、半手工