How to add hosts with yaml files?

Hello!
I know how to add the hosts via die inventory ini and GitHub, but i have no success until now with yml/yaml. i used a simple onne from here but i get the error tha yaml file would be no yaml file:

[WARNING]:  * Failed to parse /runner/project/add_nagios-ssh-rsa.yaml with yaml
plugin: We were unable to read either as JSON nor YAML, these are the errors we
got from each: JSON: Expecting value: line 1 column 1 (char 0)  Syntax Error
while loading YAML.   did not find expected node content  The error appears to
be in '/runner/project/add_nagios-ssh-rsa.yaml': line 1, column 1, but may be
elsewhere in the file depending on the exact syntax problem.  The offending
line appears to be:   ... ^ here

The yaml:

...
  hosts:
    Nagios_3_0_6:
#      ansible_ssh_common_args: "HostKeyAlgorithms=ssh-rsa"
      ansible_host: 192.168.150.20

Thank you for your Input again!

How about below ?

all:
  hosts:
    Nagios_3_0_6:
#      ansible_ssh_common_args: "HostKeyAlgorithms=ssh-rsa"
      ansible_host: 192.168.150.20

Documentation on ... is probably an ellipsis. This causes invalid yaml errors.

1 Like

Unless Iā€™m mistaken, the ellipses is actually the symbol for the end of a yaml document. The interpreter will not look past that symbol.

This file shows 1 box running 3 servers and creates 3 groups against which plays can be written.

---
  all: 
    children: 
      admin_node: 
        hosts: 
          node1admin: '' 
      managed_nodes: 
        hosts: 
          node1managed1: '' 
          node1managed2: '' 
      os_servers: 
        hosts: 
          node1.aepsc.com: '' 
    hosts: 
      node1.aepsc.com: 
       operating_system: 'Linux' 
       host_name: 'node1.aepsc.com' 
      node1admin: 
       operating_system: 'Linux' 
       host_name: 'node1.aepsc.com' 
       user_comment: 'admin server' 
      node1managed1: 
       operating_system: 'Linux' 
       host_name: 'node1.aepsc.com' 
       user_comment: 'managed node 1' 
      node1managed2: 
       operating_system: 'Linux' 
       host_name: 'node1.aepsc.com' 
       user_comment: 'managed node 2'
1 Like

i thought i have to use a ā€¦ at the beginning of every yml file.

https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html#yaml-basics

Have you tried my suggestions?
If you tried it, could you comment clearly on what the results were?
To clarify the status of this topic.

Im on it today again