Skip to main content

Ansible tricks - Chạy một role từ command line

Khi viết một role cho ansible role, thi thoảng tôi muốn chạy luôn role này. Hoặc có 1 role tôi clone được từ github. Đôi khi chỉ có một role thôi nên rất ngại viết hẳn một playbook đẻ chỉ chạy mỗi role đó.
ansible-role sẽ cứu rỗi ta, làm công việc nhanh chóng hơn.
Cài đặt ansible-role
sudo pip install ansible-role  
Sau khi cài đặt, ta thấy ansible-role có các options như

Ví dụ

  • Ta có 1 role ntp-client
Muốn chạy role này ta thực hiện lệnh sau
ansible-role --module-path .  ntp-client  ntp -i hosts -u root  
  • --module-path: Đường dẫn tới module
  • ntp-client: tên của role
  • -i hosts: inventory host
  • -u root: remote user
Kết quả
Ta có thể thấy hiện tại ansible-role đã hỗ trợ tất cả các tham số của ansible-playbook, do vậy ta có thể thoải mái làm việc với ansible-role mà ít bị hạn chế bởi những options.

Comments

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...

SIPp cheatsheet

SIPp  is a free test tool and traffic generator for the SIP protocol. It uses XML format files to define test scenarios. General usage: sipp remote_host[:remote_port] [options] Some important command-line options: -sf filename Load test scenario from specified file. -inf filename Use CSV file to insert data substituted for [field0], [field1], etc into XML scenario. First line of file describes order of inserting field sets (SEQUENTIAL/RANDOM/USE). -sn name Use one of the embedded, predefined scenarios like "uac", "uas". -r rate Scenario execution rate, default value = 10 times per period, default period = 1000 ms. -rp period Scenario execution period [ms], combined with execution rate. Execution rate is combined of rate and period parameters, i.e. if period = 3500 and rate = 7 there will be 7 calls in 3.5 s. -t transport mode Set the transport mode: "u1" - UDP, one socket (default), "un" - UDP, one socket per call, other modes (...

Creating an OpenStack development environment with an existing External Network via Packstack

Packstack provides a very simple, and very well automated process for reading development environments for OpenStack. I’d like to document here just some reproducible steps I’ve been using to set up these sorts of environments. The process for running this on a single node is very straightforward: http://haidv204.blogspot.com/2018/06/how-to-install-openstack-using-rdo.html and expanding this setup to multiple nodes is similarly straightforward; you can replace the flag --allinone with  --install-hosts=${controller_node_ip},${compute_node_1_ip},${compute_node_2_ip}... and it fires off a multi-node setup. This, however, does not assume you have external networks or other parts of your network outside of OpenStack you’d like these resources to be able to connect to. The servers in use in my environment are: Controller:  16GB RAM / 100GB Disk, 8 vCPUs  Note:  This will work with much fewer resources. I deployed this into a public cloud — for this reason, I al...