Skip to main content

Các tip hữu ích khi sử dụng ansible

Dưới đây là một số tip mình dùng khi sử dụng ansible.
VIM with YAML
Nếu bạn đã từng viết yaml trên VIM sẽ thấy một điều rất bực là tabsize default của VIM là 8 space. Mà syntax của yaml tabsize chỉ là 2space, nên nếu như không tinh chỉnh vim thì ta sẽ viết rất mệt. Ta chỉ cần thực hiện set tabsize thành 2 space khi file type là yaml như sau
Mở ~/.vimrc thêm vào dòng sau
autocmd FileType yaml setlocal ai ts=2 sw=2 et  
Sau đó mở yaml lên và thưởng thức
Check syntax
ansible-playbook hỗ trợ cho ta việc check syntax của toàn bộ 1 playbook
ansible-playbook --syntax-check <path-to-yaml-playbook>  
Nếu không có lỗi gì sẽ trả về tên của tập tin playbook đó
Step By Step
Ta cũng có thể chạy một playbook step by step, tới mỗi bước, ansible-playbook sẽ cho ta 3 lựa chọn: ync
  • y = Yes: Thực hiện task này
  • n = No: Không thực hiện task này
  • c = Continue: Chạy toàn bộ playbook mà không hỏi
PLAY [controller] **************************************************************  
Perform task: TASK: setup (N)o/(y)es/(c)ontinue: N

Perform task: TASK: setup (N)o/(y)es/(c)ontinue: *******************************  
Perform task: TASK: patch-cinder-ocata : Apply patch for cinder-volume Ocata (N)o/(y)es/(c)ontinue: y

Perform task: TASK: patch-cinder-ocata : Apply patch for cinder-volume Ocata (N)o/(y)es/(c)ontinue: ***

TASK [patch-cinder-ocata : Apply patch for cinder-volume Ocata] ****************  
ok: [capt-controller-1]  
ok: [capt-controller-3]  
ok: [capt-controller-2]  
Perform task: TASK: patch-cinder-ocata : file (N)o/(y)es/(c)ontinue: c

Perform task: TASK: patch-cinder-ocata : file (N)o/(y)es/(c)ontinue: ***********

Comments

Post a Comment

Popular posts from this blog

Zabbix, AWS and Auto Registration

One of the things I love the most with AWS is  auto-scaling . You choose an AMI, set some parameters and AWS will spin instances up and down whenever a threshold is breached. But with all these instances spinning up and down there are some unknowns. For example, what is the IP address of the new instance? Its host name? This can be critical when other components of your infrastructure are dependent on knowing these parameters. I had this problem when I started to use  Zabbix  as the monitoring system. At first it seemed like a complicated one, but Zabbix has a wonderful feature called  Auto Registration  which can be used exactly for this situation. I will try to show how to configure auto registration both on the client (EC2 instance running Ubuntu 14.04) and on the Zabbix server (Zabbix Server 2.4.2). Zabbix-agent Installation and Configuration Let’s start with installing zabbix-agent on the Ubuntu client: 1 2 $ sudo apt-get update $ sud...

Merge AVHDX Hyper-V Checkpoints

When you create a snapshot of a virtual machine in Microsoft Hyper-V, a new file is created with the  .avhdx  file extension. The name of the file begins with the name of its parent VHDX file, but it also has a GUID following that, uniquely representing that checkpoint (sometimes called snapshots). You can see an example of this in the Windows Explorer screenshot below. Creating lots of snapshots will result in many  .avhdx  files, which can quickly become unmanageable. Consequently, you might want to merge these files together. If you want to merge the  .avhdx  file with its parent  .vhdx  file, it’s quite easy to accomplish. PowerShell Method Windows 10 includes support for a  Merge-VHD  PowerShell command, which is incredibly easy to use. In fact, you don’t even need to be running PowerShell “as Administrator” in order to merge VHDX files that you have access to. All you need to do is call  Merge-VHD  with the...

Scaling Kubernetes to 2,500 Nodes

We’ve been running  Kubernetes  for deep learning research for over two years. While our largest-scale workloads manage bare cloud VMs directly, Kubernetes provides a fast iteration cycle, reasonable scalability, and a lack of boilerplate which makes it ideal for most of our experiments. We now operate several Kubernetes clusters (some in the cloud and some on physical hardware), the largest of which we’ve pushed to over 2,500 nodes. This cluster runs in Azure on a combination of D15v2 and NC24 VMs. On the path to this scale, many system components caused breakages, including etcd, the Kube masters, Docker image pulls, network, KubeDNS, and even our machines’ ARP caches. We felt it’d be helpful to share the specific issues we ran into, and how we solved them. etcd After passing 500 nodes in our cluster, our researchers started reporting regular timeouts from the  kubectl  command line tool. We tried adding more Kube masters (VMs running  kube-apiserv...