Ansible developer Atom IDE setup for playbook testing on Virtual Linux LAB


Well , its difficult to develop a playbook using YAML on linux host wherein syntax can not be verified while writing a code itself.

Atom IDE helps to develop an YAML playbook on host machine with syntax check and provide feature of remote sync to ansible controller on commit.

As pre-requiste to understand LAB & ansible setup refer ..

Step by Step Virtual Linux LAB Setup 



In this article , we will ..

1.  Install & configure IDE on Host machine   

2. Install & test syntax check package for YAML on IDE  

3. Configure remote sync & test "upload on save"

4. Run a playbook to copy a file to target virtual machine 


MYLAB-TMPL is ansible controller & MYLAB-SRV1 is target linux virtual LAB machine


Lets begin ...


1.  Install & configure IDE on Host machine  


Go to https://atom.io/ and download the setup file 


Install AtomSetup-x64.exe , run as administrator  



On successful installation click on "Open a Project"



Create same directory structure as created on Linux virtual LAB machine which will allow to sync up folder "as is" in future ..




Copy existing inventory files to project directory along with playbook 




root@mylab-tmpl:~/ansible-demo-prj/ping-test1# cat inventory.lst

target ansible_host=192.168.56.11 ansible_ssh_pass=root123

root@mylab-tmpl:~/ansible-demo-prj/ping-test1# cat ansible-ping-test.yml

-

  name: "To Test Ping response of Target server"

  hosts: target

  tasks:

        -  name: "Ping Test"

           ping:





2. Install & test syntax check package for YAML on IDE  

yaml lint provides syntax check service for yaml file http://www.yamllint.com/


With correct YAML syntax ..



With incorrect YAML syntax ..



It will be really nice if we can get this feature in IDE developer which we have installed  ..


Lets get it ..


Go to https://atom.io/packages/linter-js-yaml and click on install will get option in IDE 









Once dependent package are installed , test the syntax checking as below ...






3. Configure remote sync & test "upload on save"

Go to https://atom.io/packages/remote-sync and click on install remote-sync package which will prompt download & install on IDE






On successful installation of remote-sync , configure the remote sync as follow ..






Perform the sync test "upload on save" by changing the files in IDE and verify the change on Linux virtual LAB machine ..





On Linux virtual host 



Remove "ping" from ping module & verify sync up on save






4. Run a playbook to copy a file to target virtual machine 


Create a directory and copy inventory , playbook files





Create a sample cptest.lst file to be copied over target as a part of playbook task..



  Verify target file existence 



  Update playbook for copy module task




Run ansible-playbook command to copy the file to target virtual machine .. changed=1


Verify if file is copied on target



Re-run the command to check what happens .. changed=0






No comments:

Post a Comment