Insert Ansible YAML file example


(Ryan Nix) #1

Hello,

We’re using Discourse for our Cloud Operations group at Northwestern University. I’m trying to insert an example sensible-playbook file but the Ansible YAML formatting isn’t working. Sorry to be “That guy”, but my Google searches didn’t turn up much, probably because I’m asking the wrong question. What is the best way to insert YAML code into Discourse post so that proper spacing is preserved?


  • hosts: testing
    remote_user: root
    tasks:
    • name: "Add multiple ssh keys to the root account"
      authorized_key:
      user: root
      state: present
      key: '{{ item }}'
      with_file:
      • ~/Desktop/Certs/eudald.pub
      • ~/Desktop/Certs/mike.pub
      • ~/Desktop/Certs/russ.pub
      • ~/Desktop/Certs/ryan.pub

Should look like this:


(Joshua Rosenfeld) #2

Insert the code in a code block?

That would look like this:

- 
  hosts: testing
  remote_user: root
  tasks: 
     - name: "Add multiple ssh keys to the root account"
       authorized_key:
        user: root
        state: present
        key: '{{ item }}'
       with_file:
        - ~/Desktop/Certs/eudald.pub
        - ~/Desktop/Certs/mike.pub
        - ~/Desktop/Certs/russ.pub
        - ~/Desktop/Certs/ryan.pub

Simply add 3 backticks above and below your code.

```
Paste your code here...
```

(Ryan Nix) #3

That worked beautifully. Thanks, @jomaxro !