我想在AWS上设置一个MySQL服务器,使用Ansible进行configurationpipe理。 我正在使用Amazon的默认AMI( ami-3275ee5b ),它使用yum进行包pipe理。 当下面的Playbook被执行时,一切顺利。 但是,当我再次运行它时, Configure the root credentials的任务失败,因为MySQL的旧密码不再匹配,因为上次运行此Playbook时已更新。 这使得Playbook不具有幂等性,这是我不喜欢的。 我希望能够根据需要多次运行Playbook。 – hosts: staging_mysql user: ec2-user sudo: yes tasks: – name: Install MySQL action: yum name=$item with_items: – MySQL-python – mysql – mysql-server – name: Start the MySQL service action: service name=mysqld state=started – name: Configure the root credentials action: command mysqladmin -u root […]
是否有可能运行一个正确的剧本,看起来像这样(这是来自这个网站的一个例子: http : //docs.ansible.com/playbooks_roles.html ): – name: this is a play at the top level of a file hosts: all remote_user: root tasks: – name: say hi tags: foo shell: echo "hi…" – include: load_balancers.yml – include: webservers.yml – include: dbservers.yml 在multithreading模式? 我想在同一时间运行三个“包含”(它正在部署到不同的主机),如下图所示: http://www.gliffy.com/go/publish/5267618 可能吗?
我想使用ansible-playbook命令而不是' vagrant provision '。 但是,在hosts文件中设置host_key_checking=false似乎不起作用。 # hosts file vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key ansible_ssh_user=vagrant ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1 host_key_checking=false Vagrantfile以外的configurationvariables是否可以覆盖此值?
我可以ssh到远程主机,并做一个source /home/username/.bashrc – 一切工作正常。 但是,如果我这样做: – name: source bashrc sudo: no action: command source /home/username/.bashrc 我得到: failed: [hostname] => {"cmd": ["source", "/home/username/.bashrc"], "failed": true, "rc": 2} msg: [Errno 2] No such file or directory 我不知道我在做什么错…
我想在Python中运行Ansible而不通过(ANSIBLE_HOST)指定清单文件,只是通过: ansible.run.Runner( module_name='ping', host='www.google.com' ) 我实际上可以很容易地做到这一点,但只是想知道如何在Python中做到这一点。 另一方面,用于Python的Ansible API的文档并不完整。
我使用Ansible 1.5.3和Git与ssh代理转发( https://help.github.com/articles/using-ssh-agent-forwarding )。 我可以login到我使用Ansiblepipe理的服务器,并testing我的连接到git的configuration是否正确: ubuntu@test:~$ ssh -T git@github.com Hi gituser! You've successfully authenticated, but GitHub does not provide shell access. 我也可以使用这个帐号克隆和更新我的回购协议中的一个,这样我的gitconfiguration看起来不错,当我通过ssh直接login到服务器时,使用ssh转发。 问题:当我使用Ansible命令模块尝试上面所示的相同testing时。 它以“权限被拒绝”失败。 Ansible输出的一部分(详细logging)如下所示: failed: [xxx.xxxxx.com] => {"changed": true, "cmd": ["ssh", "-T", "git@github.com"], "delta": "0:00:00.585481", "end": "2014-06-09 14:11:37.410907", "rc": 255, "start": "2014-06-09 14:11:36.825426"} stderr: Permission denied (publickey). 这里是运行这个命令的简单的手册: – hosts: webservers sudo: yes remote_user: […]
我通过URI模块拉取JSON,并希望将接收到的内容写入文件。 我能够获取内容并将其输出到debugging器,所以我知道已经收到内容,但我不知道写入文件的最佳做法。
下面的代码只会删除它在Web目录中获得的第一个文件。 我想删除Web目录中的所有文件和文件夹,并保留Web目录。 我怎样才能做到这一点? – name: remove web dir contents file: path='/home/mydata/web/{{ item }}' state=absent with_fileglob: – /home/mydata/web/* 注意:我已经使用命令和shell尝试了rm -rf,但是它们不起作用。 也许我错误地使用了它们。 任何帮助正确的方向将不胜感激。 我正在使用2.1.0.0
我需要将文件表单机A复制到机器B,而从我运行所有我的任务的控制机器是机器C(本地机器) 我已经尝试了以下内容: 在shell模块中使用scp命令 主机:machine2 user:user2 任务: – name:将machine1中的文件复制到machine2 shell:scp user1 @ machine1:/ path-of-file / file1 / home / user2 / file1 这种方法只是继续下去,永远不会结束。 使用获取和复制模块 主机:machine1 user:user1 任务: – 名称:将machine1中的文件复制到本地 fetch:src = / path-of-file / file1 dest = / path-of-file / file1 主机:machine2 user:user2 任务: – 名称:从本地复制文件到machine2 复制:src = / path-of-file / file1 dest = / path-of-file […]
只有在当前剧本的主机不属于某个特定组的情况下,我才能够运行一个合理的任务。 在半伪代码中: – name: my command command: echo stuff when: "if {{ ansible_hostname }} not in {{ ansible_current_groups }}" 我应该怎么做?