ansible管理界面
Is anytime a good time to execute your automation workflow? The answer is probably no, for different reasons.
有什么时候可以执行自动化工作流程吗? 出于不同的原因,答案可能是否定的。
If you want to avoid simultaneous changes to minimize the impact on critical business processes and reduce the risk of unintended service disruptions, then no one else should be attempting to make changes at the same time.
如果要避免同时进行更改以最大程度地减少对关键业务流程的影响并减少意外服务中断的风险,则没有其他人可以尝试同时进行更改。
In some scenarios, there could be an ongoing scheduled maintenance window. Or maybe there is a big event coming up, a critical business time, a holiday, or you prefer not to make changes on a Friday night.
在某些情况下,可能会有一个正在进行的计划维护窗口。 或可能有大型活动即将来临,关键的工作时间,假期,或者您不想在星期五晚上进行更改。
Whatever the reason is, we want to signal this to our Automation platform and prevent the execution of periodic or ad-hoc tasks on specific time slots. In Change Management jargon we are talking about blackout windows when change activity should not occur.
无论是什么原因,我们都希望将此信号告知我们的自动化平台,并防止在特定时间段执行定期或临时任务。 在“变更管理”行话中,我们讨论的是不应发生变更活动的停电窗口。
How can we accomplish this in Ansible? While there is no Calendar function per se, however, Ansible’s extensibility will allow us to integrate with any Calendar application that has an API.
我们如何在Ansible中完成此任务? 虽然本身没有Calendar功能,但是Ansible的可扩展性将使我们能够与任何具有API的Calendar应用程序集成。
The goal is this: Before we execute any automation or change activity, we execute a pre-task that checks whether there is something already scheduled in the Calendar going on or soon enough, or to confirm we are not in the middle of a blocked timeslot.
目标是这样的:在执行任何自动化或变更活动之前,我们执行一个pre-task ,以检查日历中是否已安排某些计划正在进行或足够快,或者确认我们不在阻塞的时段中间。
Let’s pretend a fictitious module named calendar exists, and that it can connect to a remote calendar, like Google Calendar, to determine if the supplied time has been marked as busy. Then we could write a playbook that looks like this:
假设存在一个名为calendar的虚拟模块,并且该模块可以连接到远程日历(例如Google Calendar),以确定提供的时间是否已标记为忙。 然后,我们可以编写一个如下的剧本:
- name: Check if timeslot is taken calendar: time: "{{ ansible_date_time.iso8601 }}" register: outputAnsible facts will give us ansible_date_time which we pass to the calendar module to verify the time availability. We register the response (output) to use in subsequent tasks.
Ansible事实将为我们提供ansible_date_time ,我们将其传递到calendar模块以验证时间可用性。 我们注册响应( output )以用于后续任务。
If our calendar looked like this:
如果我们的日历如下所示:
Then the output of this task would highlight the fact this timeslot is taken (busy: true).
然后,此任务的输出将突出显示已占用此时隙的事实( busy: true )。
ok: [localhost] => { "output": { "busy": true, "changed": false, "failed": false, "msg": "The timeslot 2020-09-02T17:53:43Z is busy: true" } }Next, Ansible Conditionals will help us prevent the execution of any further tasks. As a simple example, you could use a when statement on the next task to enforce that it runs only when the field busy in the previous output is not true.
接下来, Ansible Conditionals将帮助我们防止执行任何其他任务。 作为一个简单的示例,您可以对下一个任务使用when语句来强制它仅在上一个输出中的busy字段不为true时才运行。
tasks: - shell: echo "Run this only when not busy!" when: not output.busyLike we mentioned in the previous post, Ansible is a framework to wire things together, interconnecting different building blocks to orchestrate an end-to-end automation workflow.
就像我们在上一篇文章中提到的那样,Ansible是一个框架,用于将事物连接在一起,将不同的构建块互连在一起,以协调端到端的自动化工作流程。
In this opportunity, we looked at how your Playbooks can integrate or talk to a Calendar application to check availability. However, we are just scratching the surface! For example, your tasks could also block a timeslot in the calendar… the sky is the limit.
借此机会,我们研究了您的Playbooks如何集成或与Calendar应用程序对话以检查其可用性。 但是,我们只是在摸摸表面! 例如,您的任务也可能会阻塞日历中的一个时隙…天空是极限。
In the next post, we will dig into how we actually built this calendar module and how other programming languages can be used with Ansible. Stay tuned if you are a Go fan like me!
在下一篇文章中,我们将深入研究如何实际构建此calendar模块以及如何在Ansible中使用其他编程语言。 如果您是像我这样的围棋迷,请继续关注!
翻译自: https://medium.com/swlh/ansible-and-google-calendar-integration-for-change-management-7c00553b3d5a
ansible管理界面
相关资源:ansible管理lvm-源码