XCP-ng

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Ansible plugin, usage with AWX.

    Xen Orchestra
    3
    14
    509
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • olivierlambert
      olivierlambert Vates 🪐 Admin 🧑‍💻 last edited by

      A question for @shinuza 🙂

      1 Reply Last reply Reply Quote 0
      • S
        shinuza @Tristis Oris last edited by shinuza

        @tristis-oris Hey, so yeah. The doc was confusing, I've created a pull request to fix it.

        As for your issue. It says auto plugin: [Errno 111] Connection refused, meaning you can't connect to the API from the machine that tries to execute the inventory.

        Tristis Oris 1 Reply Last reply Reply Quote 0
        • Tristis Oris
          Tristis Oris @shinuza last edited by

          @shinuza but no refused error with a structure:

          simple_config_file:
              plugin: community.general.xen_orchestra
          
          S 1 Reply Last reply Reply Quote 0
          • S
            shinuza @Tristis Oris last edited by

            @tristis-oris As I said, this was an error in the example config. You need to use

              plugin: community.general.xen_orchestra
              api_host: ip
              user: awx
              password: awx
              validate_certs: no
              use_ssl: no
            
            Tristis Oris 1 Reply Last reply Reply Quote 0
            • Tristis Oris
              Tristis Oris @shinuza last edited by

              @shinuza got it. any reason why it can be refused?
              i created a user account, is it enough?
              or a screening password.

              S 1 Reply Last reply Reply Quote 0
              • Tristis Oris
                Tristis Oris last edited by

                with a

                plugin: community.general.xen_orchestra
                api_host: ip
                user: awx
                password: "awx"
                validate_certs: no
                use_ssl: no
                

                i got

                ansible-inventory [core 2.11.7.post0] 
                  config file = None
                  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
                  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
                  ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections:/usr/share/automation-controller/collections
                  executable location = /usr/local/bin/ansible-inventory
                  python version = 3.8.8 (default, Aug 25 2021, 16:13:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
                  jinja version = 2.10.3
                  libyaml = True
                No config file found; using defaults
                setting up inventory plugins
                host_list declined parsing /runner/project/inventory/xen_orchestra.yml as it did not pass its verify_file() method
                script declined parsing /runner/project/inventory/xen_orchestra.yml as it did not pass its verify_file() method
                Loading collection community.general from /usr/share/ansible/collections/ansible_collections/community/general
                toml declined parsing /runner/project/inventory/xen_orchestra.yml as it did not pass its verify_file() method
                [WARNING]:  * Failed to parse /runner/project/inventory/xen_orchestra.yml with
                auto plugin: 'result'
                  File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 290, in parse_source
                    plugin.parse(self._inventory, self._loader, source, cache=cache)
                  File "/usr/local/lib/python3.8/site-packages/ansible/plugins/inventory/auto.py", line 58, in parse
                    plugin.parse(inventory, loader, path, cache=cache)
                
                1 Reply Last reply Reply Quote 0
                • S
                  shinuza @Tristis Oris last edited by

                  @tristis-oris It's not a credentials issue, if it was the plugin would explicitly say so. Errno 111 means the low-level socket connection can't be established. Try connecting with telnet?

                  Tristis Oris 1 Reply Last reply Reply Quote 0
                  • Tristis Oris
                    Tristis Oris @shinuza last edited by

                    @shinuza both VM in same network, disabled firewall at orchestra.
                    same error. what it could be?

                      File "/usr/local/lib/python3.8/site-packages/websocket/_http.py", line 130, in connect
                        sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
                      File "/usr/local/lib/python3.8/site-packages/websocket/_http.py", line 208, in _open_socket
                        raise err
                      File "/usr/local/lib/python3.8/site-packages/websocket/_http.py", line 185, in _open_socket
                        sock.connect(address)
                    [WARNING]:  * Failed to parse /runner/project/inventory/xen_orchestra.yml with
                    yaml plugin: Plugin configuration YAML file, not YAML inventory
                      File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 290, in parse_source
                        plugin.parse(self._inventory, self._loader, source, cache=cache)
                      File "/usr/local/lib/python3.8/site-packages/ansible/plugins/inventory/yaml.py", line 112, in parse
                        raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
                    [WARNING]:  * Failed to parse /runner/project/inventory/xen_orchestra.yml with
                    ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not
                    allowed, this character is reserved to provide a port.
                      File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 290, in parse_source
                        plugin.parse(self._inventory, self._loader, source, cache=cache)
                      File "/usr/local/lib/python3.8/site-packages/ansible/plugins/inventory/ini.py", line 136, in parse
                        raise AnsibleParserError(e)
                    [WARNING]: Unable to parse /runner/project/inventory/xen_orchestra.yml as an
                    inventory source
                    ERROR! No inventory was parsed, please check your configuration and options.
                    
                    S 1 Reply Last reply Reply Quote 0
                    • S
                      shinuza @Tristis Oris last edited by

                      @tristis-oris It's hard to say remotely, you could try install xo-cli on the same machine you are trying to run ansible-inventory.

                      Maybe there will be more details on why the connection is failing.

                      Tristis Oris 1 Reply Last reply Reply Quote 0
                      • Tristis Oris
                        Tristis Oris @shinuza last edited by

                        @shinuza it's a password.

                        with long one with symbols xo-cli can't register.
                        changed to simple, it works now.

                        tried "" or '' in playbook, it didnt work.

                        1 Reply Last reply Reply Quote 0
                        • Tristis Oris
                          Tristis Oris last edited by

                          is it any way to translate uuid to names at inventory?

                          S 1 Reply Last reply Reply Quote 0
                          • S
                            shinuza @Tristis Oris last edited by

                            @tristis-oris Nope, unfortunately:

                            • ansible needs a stable unique id to identify hosts
                            • name-labels from the xo api are not stable and may not be unique
                            • if a vm doesn't have the guest-tools installed then we cannot know its ip and or hostname.
                            • the only property that's stable between pools, hosts and vms are the uuid

                            Using hostnames or ip as inventory id means there's no way to for example to: start a vm using the inventory, but you can do it using the inventory and a JSON-RPC call.

                            Tristis Oris 1 Reply Last reply Reply Quote 0
                            • Tristis Oris
                              Tristis Oris @shinuza last edited by Tristis Oris

                              @shinuza got it, thanks. sad of course(

                              "ansible needs a stable unique id to identify hosts"
                              not realy, with manual host lists awx download new every time and remove old\chenged info.
                              same for netbox integration.

                              for most of task just enough tags like linux, db, etc.

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post