Visual Studio Code Editor for Ansible on RHEL8

step1: Import Microsoft GPG key

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc


step2: create the following repo file to enable the Visual Studio Code repository
sudo vi /etc/yum.repos.d/vscode.repo

Paste the following content into the file:


name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

 

step3: Install Visual Studio Code Editor
sudo yum install code

step4: Launch visual studio code using termainal
code .

step5: Add Required Extensions

ansible extention/plugin

 

step6: Install Required Extensions

 

Step7 I create test playbook to test

I find some disk.yml on https://geekflare.com/ansible-playbook-windows-example/

lets test it 🙂

$ vi disk.yml
---
- hosts: win
  tasks:
  - name: Get disk facts
    win_disk_facts:

  - name: Output first disk size
    debug:
      var: ansible_facts.disks[0].size

  - name: Convert first system disk into various formats
    debug:
      msg: '{{ disksize_gib }} vs {{ disksize_gib_human }}'
    vars:
      # Get first system disk
      disk: '{{ ansible_facts.disks|selectattr("system_disk")|first }}'

      # Show disk size in Gibibytes
      disksize_gib_human: '{{ disk.size|filesizeformat(true) }}'
      disksize_gib: '{{ (disk.size/1024|pow(3))|round|int }} GiB'


Step8: Right click and Run Ansible Playbook Remotly via SSH

 

Step9: Add (hostname, port  , user, password )

hostname-  Ansible server (192.168.1.111) 

port: 22

SSH username : 

password: XXXXXX

 

You should see on terminal some input from you servers

Thanks more Ansible soon 🙂

 

 

Please Comment and Subscribe

 

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *