Ansible snippets - manipulating JSON data

Ansible snippets - manipulating JSON data

Recently while working with Ansible, I needed a clean way to extract JSON values and manipulate that data in a very Ansible-esque way. In this particular case, reading JSON files/variables and treating them as if they were Ansible variables, converting that list into a comma-seperated string. Turns out Ansible can handle that pretty easily, using Jinja filters. scenario and demo The following steps will use the example playbook json_example.yml. Let’s say you need to extract JSON values from a file (or variable), for use somewhere else.
deploying a Bitcoin node to Google Cloud using Terraform and ansible-pull

deploying a Bitcoin node to Google Cloud using Terraform and ansible-pull

This was some additional work cooked up; very similar to the AWS deployment, it’s a Terraform and Ansible deployment of a Bitcoin node, but instead a deployment to Google Cloud. https://github.com/bonovoxly/bitcoin-node/tree/master/terraform/gcloud Overall, not a lot different once the credentials for Google Cloud gets setup. Terraform away and a Bitcoin node is operational. I added extensive notes on configuring Google Cloud credentials. One of the cool things about Google Cloud was the built-in SSH access.
deploying a Bitcoin node using Terraform and ansible-pull

deploying a Bitcoin node using Terraform and ansible-pull

Update - 2017-11-23 - I’ve updated the bitcoin-node repository to also include Terraform instructions on deploying to Google Cloud. This was a fun one; in an attempt to keep deployment instructions super simple, I dug into ansible-pull a bit. I kind of liked it. Using ansible-pull, triggered by Terraform and an AWS User Data shell script, a Bitcoin full node can be deployed using a single terraform apply. overview The goal here was simple; deploy a full Bitcoin node, for additional network capacity.
ansible stuffs - controlling shell tasks using creates, find, and until

ansible stuffs - controlling shell tasks using creates, find, and until

The Ansible shell module is a straightforward tool. With some conditionals and functions, it’s usefulness can be improved and tasks can be quite smart. This post explores three Ansible conditionals/functions, creates, find, and until. creates causes shell to run only if a file does not exist, find causes shell to run only once if certain output exists, and using until and find causes a command to run repeatedly waiting for specific output.

deploying kubernetes 1.7.3 using Terraform and Ansible

what and why In a previous post, I walked through an infrastructure deployment of a Kubernetes stack to AWS.. I have come back to it a few times, attempting to clean up the documentation, clean up the process, and improving the accessibility of the overall project. This time, I wanted to modernize it to match the current major release of Kubernetes. But there were other reasons and by modernizing this, it would allow me to explore some interesting topics like NGINX ingress controllers, Prometheus, OAuth integration, Istio, Helm, and Kubernetes Operators.

gathering public SSH keys from the AWS System Log and creating custom SSH host entries using Ansible

what is this and why? I work in private VPCs in AWS a lot. I’m testing, debugging, and fidgeting with instances, requiring SSH access. If DNS isn’t configured, I’ve then had to look up IP addresses for instances through the AWS console (or just memorize the IP). After that, there’s the SSH public host key fingerprint. I either blindly accept it or manually look it up. If I terminate and redeploy the instance, there’s a chance I’ll get that SSH WARNING!

Ansible Jinja expressions

Use a default variable: # Sets the region variable to the value of "my_region" or defaults to 'us-east-1'. region: "{{ my_region | default('us-east-1') }}" # Sets the region variable to the value of "my_region" or defaults to whatever "your_region" is. region: "{{ my_region | default(your_region) }}" Convert an Ansible variable to an integer and increment it. # convert to an integer and increase by 1. # this is a string, not an integer string: "3" # this will equal 4.

some ansible variables

ec2_facts # These are the instance local ec2_facts keys. "ansible_facts" "ansible_ec2_ami_id" "ansible_ec2_ami_launch_index" "ansible_ec2_ami_manifest_path" "ansible_ec2_block_device_mapping_ami" "ansible_ec2_block_device_mapping_ephemeral0" "ansible_ec2_block_device_mapping_ephemeral1" "ansible_ec2_block_device_mapping_root" "ansible_ec2_hostname" "ansible_ec2_iam_info" "ansible_ec2_iam_security_credentials_demo_etcd_role" "ansible_ec2_instance_action" "ansible_ec2_instance_id" "ansible_ec2_instance_type" "ansible_ec2_local_hostname" "ansible_ec2_local_ipv4" "ansible_ec2_mac" "ansible_ec2_metrics_vhostmd" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_device_number" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_interface_id" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_local_hostname" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_local_ipv4s" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_mac" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_owner_id" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_security_group_ids" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_security_groups" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_subnet_id" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_subnet_ipv4_cidr_block" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_vpc_id" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_vpc_ipv4_cidr_block" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_vpc_ipv4_cidr_blocks" "ansible_ec2_placement_availability_zone" "ansible_ec2_placement_region" "ansible_ec2_profile" "ansible_ec2_public_key" "ansible_ec2_reservation_id" "ansible_ec2_security_groups" "ansible_ec2_services_domain" "ansible_ec2_services_partition" "ansible_ec2_user_data" ec2_remote_facts # These are the ec2_remote_facts keys. "instances" "ami_launch_index" "architecture" "block_device_mapping" "attach_time" "delete_on_termination" "device_name" "status" "volume_id" "client_token" "ebs_optimized" "groups" "id" "name" "hypervisor" "id" "image_id" "instance_profile" "arn" "id" "interfaces" "id" "mac_address" "kernel" "key_name" "launch_time" "monitoring_state" "persistent" "placement" "tenancy" "zone" "private_dns_name" "private_ip_address" "public_dns_name" "public_ip_address" "ramdisk" "region" "requester_id" "root_device_type" "source_destination_check" "spot_instance_request_id" "state" "tags" "Environment" "Name" "Role" "sshUser" "terraform_id" "virtualization_type" "vpc_id" "ami_launch_index" "architecture" "block_device_mapping" "attach_time" "delete_on_termination" "device_name" "status" "volume_id" "client_token" "ebs_optimized" "groups" "id" "name" "hypervisor" "id" "image_id" "instance_profile" "arn" "id" "interfaces" "id" "mac_address" "kernel" "key_name" "launch_time" "monitoring_state" "persistent" "placement" "tenancy" "zone" "private_dns_name" "private_ip_address" "public_dns_name" "public_ip_address" "ramdisk" "region" "requester_id" "root_device_type" "source_destination_check" "spot_instance_request_id" "state" "tags" "Environment" "Name" "Role" "sshUser" "terraform_id" "virtualization_type" "vpc_id" Get a variable from another hosts "{{< hostvars['127.

stuffs - an AWS inventory tool

problem I wanted to create a simple inventory website. I wanted to have a collection of information, including all systems, installed software on those systems, and any other relevent stats and details on those systems. The available tools out there, however, I didn’t really like. I just wanted a simple static HTML site, with possible some search features. Why not use some free software out there to generate my own?

another Terraform Ansible Kubernetes

Note - I have updated this for Kubernetes 1.7.x. Deploying Kubernetes, complete with an OpenVPN access point, a CFSSL x509 certificate generation service, and an internal Kubernetes cluster DNS, complete with a Weave CNI daemonset, and kube-dns, the Kubernetes internal DNS resolver. It is a two part process; first, using Terraform, it builds the AWS infrastructure, including VPC settings, IAM roles, security groups, instances, etc. Once the infrastructure is deployed, Ansible is then used to configure the system accordingly.