Playbook Editor

I’ve not used Windows since '98, sorry…

My enviroment is WSL on windows works fine with vscode

Used Plugins:
ansible
ansible Core snipets
indent-rainbow

i test localy inside a virtual envirtoment in python when that works i push the submodule. And my awx controller has a webhook that picks up the changes.

And then i can executte the playbook / roles on a remote machine.

I have used to work on a remote server but that returned me some issues next week i need to pick this back up since a new engineer wil joining the ansible squad.

So i will test the same out vscode on a remote server with ssh signing should work the same.

Hi Alainsyes,

Thanks for the reply. This is my problem I know virtually nothing about wsl, or you mentioned python, I am not even sure how vscode works. For example I can create a small simple Ping playbook but have absolutely no idea how to actually run it from vcode once I have SSH to my Linux server.

Perhaps I don’t even need to ssh to my Linux server - can I create the playbook in vscode save the file, transfer to Linux and then run it from there, or even run directly from vscode.

Any help, guidance would be extremely usefull.

Thanks.

I’m an old curmudgeon, so feel free to ignore me…

… However, I do think there’s value in slogging through your first playbooks with minimal tools, typing in all the keywords and values, messing up and fixing the indentation by hand, etc. True, it forces you to slow down. But that’s the point. It’s important to learn at a low level how all the pieces work together. Then as you add more powerful tools, not only can you better appreciate what they do for you, you’re better able to cope when something’s not right.

There’s a risk that you’ll reach a high-enough plateau to be marginally productive without ever learning to take advantage of all the fancy features of tools like VSCode. [Looks at mirror; yep, there I am.] That’s a personal decision, though, of when to focus on X vs. Y. Sometimes you have to get stuff done; sometimes you take the time to learn how to do it better tomorrow.

Good luck!

2 Likes

You should have ssh connection to your remote server then you can use the remote server

to test the code first localy you can use some local parameters like you can see bellow

---
- name: Query netbox test
  hosts: localhost # Local testing parameters - remote server should be here
  connection: local # If remote remove this
  
  tasks:
    - name: GET > available IPS from the specified range
      ansible.builtin.uri:
        url: "{{ NETBOX_API_URL}} ipam/ip-ranges/{{ ip_range_id }}/available-ips/"
        method: GET
        headers:
          Authorization: "Token {{ netbox_api_token }}"
        validate_certs: false

How i started with ansible is first local on the server itslef using vi.
Then moved to vscode on a remote server, then i introduced myself with awx controller.

Then added WSL to my dev stack with git repos to awx and now this is still my development flow (i dont test localy anymore , i test on some development servers where a snapshot is been created before executed).

2 Likes

Hy i come back to this again i have tested this out with a remote server the only issues you might run into on a remote server. Is that you need to setup a ssh key and a fixed user to run remotly on the server.

Then you can add ansible & ansible-lint inside a virtual pyhthon enviroment to do your develoment.

I still recomend WSL it takes all of the hasle away from a remote server and if you setup your flow with git, you can easy deploy to a production enviroment with git or with AWX / Tower.

This is my dev stack
Local:

  • WSL (python virtual enviroment with the depencies i need)
  • Python Dependencies: ansible, ansible-lint,jmeshpath,pywinrm,pyVim
  • VSCODE
  • Plugins: Ansible, indent-rainbow, rainbox-csv, YAML
  • Git

my flow is :

test code locally , when i am satified with the results is push te code in to the submodule in git.

in my awx controller i have a webhook that pulls in the code from git

I’m intrigued by this bit. How are your projects structured such that git submodules play a part? We had talked about submodules at one point (long ago), and we didn’t see a problem at the time for which submodules looked like the solution - for us. I’d happily revisit the idea, though.

Hy @utoddl ,

my project sturcture is like this

  • linux
    • modules
      • unattended-updates (submodule)
      • user-management (submodule)
      • firewall-management (submodule)
  • windows
    • modules
      • firewall-managemnt (submodule)

With cetain submodules i have a webhook attached so if a dev changes a module this triggers the webhook on the awx part and the hosts that are using that role are getting the latest changes.

Interesting. We’re kind of like that, except we’re an all-Linux shop (not judging!), and what you have as submodules are for us each a role – of 51 at the moment – in one mega-project. It’s a small enough team that more granularity didn’t seem necessary. Roles range from auditd to zabbix; some with single-digit file counts, but four of them have over 80 files each. And we have 189 host_vars files, 271 group_vars files in the one project. We do a bunch of name-based variable merging, too.

You don’t see such numbers shared much in public, so I have no idea how that compares to other real-world projects. [maybe should run a pole… hmm.]

VS Code also has an Ansible extension.

Submodules gives us the flex that we can assign a developer to a specefic role without exposing the full project to him.

It is al depending on how your workflows are setup

1 Like

I second this. I highly recommend learning visual studio code! Here is a quick video I made: https://youtube.com/shorts/UFPpr2L7YDg?si=jQW20TKmAaA22uVB