无法使用Ansible创建单个用户

时间:2019-11-21 16:06:09

标签: authentication ansible

我正在尝试运行有史以来最简单的Ansible脚本。但是我不能,因为我遇到以下错误:

        XmlWriterSettings settings = new XmlWriterSettings
        {
            OmitXmlDeclaration = true
        };

        XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
        ns.Add("", "");

        StringBuilder sb = new StringBuilder();

        XmlSerializer xs = new XmlSerializer(typeof(BankingDetails));

        using (XmlWriter xw = XmlWriter.Create(sb, settings))
        {
            xs.Serialize(xw, model, ns);
            xw.Flush();
            return sb.ToString();
        }

错误:

---
- hosts: all
  tasks:
      - name: Create single user
        user: name="matias" password="secret" shell="/bin/bash"

我的命令:

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
'all'

ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

The error appears to be in 'matias/tasks/main.yml': line 3, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

# Example playbook that shows how to create users from the generated ansible variable file
- hosts: all
  ^ here

我在这里做什么错了?

1 个答案:

答案 0 :(得分:1)

我想您在/ etc / ansible / hosts目录中没有提到任何主机名。您可以将主机保存在/ etc / ansible / hosts中。 Ansible将其视为默认位置。