如何将role1中定义的变量传递给ansible中的role2?
我想知道做这件事的最好方法
---
- name: deploy VM
hosts: localhost
roles:
- deploy_vm ## Here I want to deploy the VM and get the VM name/IP address in variable.
- deploy_tomcat_on_above_vm ## I would like to use the VM name and pass it over the second role.
我想使用VM名
我在meta/main.yml中声明了我的角色的依赖项。
---
dependencies:
- role: angstwad.docker_ubuntu
src: https://github.com/angstwad/docker.ubuntu
scm: git
version: v2.3.0
然而,当我尝试执行Ansible剧本时,我看到的是错误消息:
ERROR! the role 'angstwad.docker_ubuntu' was not found in /home/.../ansible/roles:/etc/ansible/ro
运行以下攻略语法似乎是正确的,但得到以下错误!-
ERROR! 'blockinfile' is not a valid attribute for a Play
The error appears to have been in '/root/playbook1.yml': line 2, column 3, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: insert
我正在写一本ansible攻略,为我提供一个web服务器。这个过程的一部分涉及到使用geerlingguy/ansible- role -security角色(我用它来更改默认的ssh端口)。然而,由于端口发生了变化,您不能在不更改ansible_ssh_port变量的情况下反复运行剧本。这似乎与幂等性的整个观点背道而驰,因为您必须在两次运行之间编辑剧本。所以我想知道是否有一种方法来描述ansible可以尝试的两个端口。这样,它将在脚本第一次运行时使用端口22,但在所有其他时间它将使用另一个端口。
我尝试过尝试不同的端口,但我什么也找不到。
我已经编写了一个行动手册,用于在resolv.conf中添加一个条目并添加一个新用户。我在not present in target system中指定的组,但是我在模拟运行(使用--check)选项时没有得到错误,而是在实际运行中得到了错误。
[root@ansible-controller ansible-test-project]# ansible-playbook lineinfile-playbook.yaml -i inventory.txt --check
PLAY [Add a new nameserver and webuser] ********************
我尝试运行Ansible模块junos_cli和junos_rollback,得到以下错误:
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to have been in '/home/quake/network-ansible/roles/junos-rollback/tasks/main.yml': line 2, column 3, but may
be elsewh
我们有3个仓库,比如说回购Y,Z和W。
存储库W下有存储库Y和Z希望使用的角色。
从阅读来看,我们似乎需要将requirements.yml设置如下:
- src: git@github.com:SOMEREPOSITORY/test-role.git
version: main
name: test_role
但是,我们仍然没有成功地使用共享角色,
ERROR! the role 'test_role' was not found in /home/coder/provision/Build/roles:/home/coder/.ansible/roles: