All of the posts on orchestration on here have been about Puppet on CentOS however last week I had need to script an AWS architecture and then launch instances built with Packer into it.
After much swearing I managed to hack together a python script which used Boto to create a launch configuration and register it with an auto-scaling group, I then used a second script which re-cycled instances behind the Elastic Load Balancer which were launched with the previous launch configuration.
I decided there must be a more elegant way of doing this so I looked at Puppet using it to manage AWS, there are some modules available but there was a lot of people discussing the various ways to configure a VPC using Puppet. Then I remember that learning the basics of Ansible was on my list of things to do.
As Ansible is agent-less I needed to install it on my Mac, this is simple enough as you can use BrewĀ ā¦.
brew updatebrew install ansible⦠once install I used a CentOS 7 Vagrant box to work through a few tutorialsĀ ā¦
russ @ Russs-iMac in ~/Desktop/ansiblevagrant upBringing machine ādefaultā up with āvirtualboxā providerā¦==> default: Importing base box āzoresvit/centos-7.0āā¦==> default: Matching MAC address for NAT networkingā¦==> default: Checking if box āzoresvit/centos-7.0ā is up to dateā¦==> default: Setting the name of the VM: ansible-000dd0c7684e44d25776288b71d594e00234a0ad_default_1418570825018_9435==> default: Clearing any previously set network interfacesā¦==> default: Preparing network interfaces based on configurationā¦default: Adapter 1: natdefault: Adapter 2: hostonly==> default: Forwarding portsā¦default: 22 => 2222 (adapter 1)==> default: Running āpre-bootā VM customizationsā¦==> default: Booting VMā¦==> default: Waiting for machine to boot. This may take a few minutesā¦default: SSH address: 127.0.0.1:2222default: SSH username: vagrantdefault: SSH auth method: private keydefault: Warning: Connection timeout. Retryingā¦==> default: Machine booted and ready!==> default: Checking for guest additions in VMā¦==> default: Setting hostnameā¦==> default: Configuring and enabling network interfacesā¦==> default: Mounting shared foldersā¦default: /share => /Users/russ/Desktop/ansible/sharedefault: /vagrant => /Users/russ/Desktop/ansible==> default: Running provisioner: ansibleā¦
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************ok: [default]
TASK: [common | install ntp] **************************************************changed: [default]
TASK: [common | check ntpd service is stopped] ********************************changed: [default]
TASK: [common | ntpdate] ******************************************************skipping: [default]
TASK: [common | ntp config file] **********************************************changed: [default]
TASK: [common | start ntpd service] *******************************************changed: [default]
NOTIFIED: [common | restart ntpd] *********************************************changed: [default]
PLAY RECAP ********************************************************************default : ok=6 changed=5 unreachable=0 failed=0⦠like all first steps using a new orchestration tool I had installed & configured NTPD.
The syntax itself isnāt too different from Puppet so it was easy to get the gist of what was going on. Once I had gotten my head around the basics I started on creating a Playbook which configures a VPC and launches an Elastic Load BalancerĀ , here is the current work in progressĀ ā¦
- name: install ntp yum: pkg=ntp state=installed- name: check ntpd service is stopped shell: "service ntpd status | grep -q stopped; echo $?" register: result- name: ntpdate command: ntpdate 0.uk.pool.ntp.org when: result.stdout == "0"- name: ntp config file template: src=roles/common/templates/ntp.conf.j2 dest=/etc/ntp.conf owner=root group=root mode=0644 notify: - restart ntpd- name: start ntpd service service: name=ntpd state=started enabled=yesOnce I have everything working as expected I will post an update.



