获取错误“您需要是root才能执行此命令”ansible playbook
我跑在剧本下面。它将使用ec2用户登录到服务器,但将安装mysql java连接器,即我的test1用户获取错误“您需要是root才能执行此命令”ansible playbook,ansible,Ansible,我跑在剧本下面。它将使用ec2用户登录到服务器,但将安装mysql java连接器,即我的test1用户 --- - hosts: cluster become: yes remote_user: ec2-user tasks: - name: Create test1 User user: name: test1 password: '$6$jQX0JQzf8GB$NI/Pv1rMLyxWYaFCGNsbrun3sfn5bXSzg89
---
- hosts: cluster
become: yes
remote_user: ec2-user
tasks:
- name: Create test1 User
user:
name: test1
password: '$6$jQX0JQzf8GB$NI/Pv1rMLyxWYaFCGNsbrun3sfn5bXSzg89Ip.ga2yf3n7hhrjiPsEo5IChIA7X8xVxnuZzm2sWA7IRM6qZOR0'
state: present
shell: /bin/bash # Defaults to /bin/bash
system: no # Defaults to no
createhome: yes # Defaults to yes
home: /home/test1
- name: Add users to sudoers
lineinfile:
dest : /etc/sudoers
state: present
line: 'test1 ALL=(ALL) NOPASSWD: ALL'
- name: Install mysql java connector
become_user: test1
become_method: sudo
yum: name=mysql-connector-java state=present
获取以下错误:
fatal: [xxx.xxx.xxx.211]: FAILED! => {"changed": false, "msg": "You need to be root to perform this command.\n", "rc": 1, "results": [""]}
将been_user:test1替换为been_user:root或删除此行,因为been_user默认为root
有关详细信息,请阅读。将BENG_user:test1替换为BENG_user:root或删除此行,因为BENG_user默认为root
有关详细信息,请阅读。在/etc/ansible/hosts文件中添加ansible\u user=Your user和ansible\u been=true以删除此错误:
您需要是root用户才能执行此命令
在/etc/ansible/hosts文件中添加ansible\u user=Your user和ansible\u been=true以删除此错误:
您需要是root用户才能执行此命令
同样的错误,您应该包括成为和成为用户。在某些情况下,添加成为方法 变成 设置为“是”以激活权限提升 成为用户 设置为具有所需权限的用户-您成为的用户,而不是您登录时的用户。并不意味着变成:是,允许设置它 在东道国一级。默认值为root
同样的错误,您应该包括成为和成为用户。在某些情况下,添加成为方法 变成 设置为“是”以激活权限提升 成为用户 设置为具有所需权限的用户-您成为的用户,而不是您登录时的用户。并不意味着变成:是,允许设置它 在东道国一级。默认值为root
我想使用具有sudo权限的test1用户进行安装。如果我使用been_user:root,意味着我是通过root用户安装它的。与大多数用户一样,使用apache用户而不是根用户安装和运行apache。如果只有测试用户具有完全sudo权限,则使用远程用户:测试而不是远程用户:ec2用户。无论如何,yum只能从root用户开始工作。要从非root用户运行服务,您应该在安装后重新配置服务。但在您的示例中没有服务启动,只有安装。使用yum安装只能从root用户进行。我想使用具有sudo权限的test1用户进行安装。如果我使用been_user:root,意味着我是通过root用户安装它的。与大多数用户一样,使用apache用户而不是根用户安装和运行apache。如果只有测试用户具有完全sudo权限,则使用远程用户:测试而不是远程用户:ec2用户。无论如何,yum只能从root用户开始工作。要从非root用户运行服务,您应该在安装后重新配置服务。但在您的示例中没有服务启动,只有安装。使用yum安装只能从root用户进行。有关更多信息,请访问:有关更多信息,请访问:
- hosts: somehost
name: Install something
become: yes
remote_user: yourname