Recently, I was working on setting up a redis cluster along with separate users for readwrite and readonly. I setup the readonly user using the below privileges (ACLs): user redisreadonly on >mySuperSecretPassword ~* resetchannels -@all +@read +ping +asking Once this is setup, I wrote a simple program in python to connect to the redis cluster using the readonly credentials and print the number of keys. #!/usr/bin/env python3 """ pip3 install redis """ from redis.cluster import RedisCluster, ClusterNode # ─────── Cluster connection ─────── startup_nodes = [ ClusterNode("redis_host_1", 6379), ClusterNode("redis_host_2", 6379), ClusterNode("redis_host_3", 6379) ] rc = RedisCluster(startup_nodes=startup_nodes,decode_responses=True,username='redisreadonly',password='mySuperSecretPassw...
AWS using Ansible? Yes, it's possible!
- Get link
- X
- Other Apps
Although, I've used Ansible extensively for a lot of automation and orchestration tasks, using Ansible for AWS was indeed, a new territory for me.
This turned out to be a blessing, since along with using Ansible for AWS tasks, I also learnt how to use WSL (Windows Subsystem for Linux) on a Windows machine.
Though WSL's been around for some time, I still hadn't come around to using it since I was mostly using my Macbook pro. Not anymore, though!
Anyway, I have listed below the steps to:
- Install WSL on Windows 11 23H2 patch
- Install AWS CLI on Ubuntu 22.04 (Exact version - 22.04.3 LTS)
- Install Ansible and the amazon.aws collection
- Use AWS CLI to get the list of VPCs in the region - us-east-1 (or a region of your choice)
- Create a python file/script to get the list of VPCs in the region - us-east-1 (or a region of your choice)
- Create an Ansible playbook to get the list of VPCs in the region - us-east-1 (or a region of your choice.
You may download the complete installation instructions/steps from github.
Download the python script - describe_vpcs.py and the ansible playbook - get_vpc_info.yaml from github.
I hope this helps you get started on your journey to using Ansible for AWS.
Popular posts from this blog
Elasticsearch: Get output in CSV format using curl and jq
If you've used elasticsearch , you'll know that each call to it has to be through REST APIs, either using Kibana , curl, postman or similar tools. If you are like me, then curl is the way to go! However, that does pose one problem - how does one select specific fields, akin to select statements of SQL/RDBMS DBs? The answer is using jq , the lightweight and flexible command-line JSON processor. This is my use-case: I have an elasticsearch cluster in which daily snapshots are scheduled and I would like to get the output of snapshot name, snapshot repo, name of the SLM policy etc., in a comma separated row format so that I can directly use it to push that data to my backup catalog in PostgreSQL. So, I query "_snapshot/<snapshot_repo>/backup_name_start_string*" and the output is quite long and convoluted (the more the backups, the longer the output)! Here, I present the way to shorten the output as well as to fetch it in row based CSV format, easier to understa...
EXCEPTION_ACCESS_VIOLATION in Jinitiator and IE crashes
The Environment Apps Version : 11.5.10.2 Jinitiator Version : 1.3.1.26 Internet Explorer Version : 6 The Issue One of our end users was receiving a very strange error while using jinitiator. The Internet explorer window would crash (close by itself) after creating a file HS_ERR_PID .log on the desktop, where #### stands for the Process ID of the f60webmx session. This error is intermittent and not easily reproducible. Moreover, the user would have to redo his/her work and hence this issue was turning out to be very vexing indeed. The error log is as below: An unexpected exception has been detected in native code outside the VM. Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D043D1AFunction name=Java_sun_java2d_loops_DefaultComponent_IntIsomorphicCopy Library=C:\Program Files\Oracle\JInitiator 1.3.1.26\bin\awt.dll Current Java thread: at sun.java2d.loops.DefaultComponent.IntIsomorphicCopy(Native Method) at sun.java2d.loops.IntRgbToIntRgb.OpaqueBlit(Unknown Source) at ...
Redis user permissions (ACL) and python connection
Recently, I was working on setting up a redis cluster along with separate users for readwrite and readonly. I setup the readonly user using the below privileges (ACLs): user redisreadonly on >mySuperSecretPassword ~* resetchannels -@all +@read +ping +asking Once this is setup, I wrote a simple program in python to connect to the redis cluster using the readonly credentials and print the number of keys. #!/usr/bin/env python3 """ pip3 install redis """ from redis.cluster import RedisCluster, ClusterNode # ─────── Cluster connection ─────── startup_nodes = [ ClusterNode("redis_host_1", 6379), ClusterNode("redis_host_2", 6379), ClusterNode("redis_host_3", 6379) ] rc = RedisCluster(startup_nodes=startup_nodes,decode_responses=True,username='redisreadonly',password='mySuperSecretPassw...
Comments