Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.
wilornel
I feel like we are missing context to help
wilornel
Matthew Davis: Thanks
wilornel
Matthew Davis (Gitter): Thanks
wilornel
I'm getting a new issue
wilornel
amazon-ebs: mkdir: cannot create directory '/root': Permission denied
wilornel
what is trying to create a root dir? The roles I'm using?
wilornel
Looks like there's an issue on this that was closed by ansible with no further comment? ansible/ansible#31145
wilornel
geerlingguy/packer-ubuntu-1604#3 and ansible/ansible#25414 and ansible/ansible#16593 are the issue.
wilornel
Now, I don't know the best way to wait.
with_item:
- { path: C:\ansible\apps\software\Notepad++\npp.7.5.3.Installer.x64.exe, arguments: /S }
^ here
dziendobry
Hi. I would like to know if someone can help me a on ansible-vault. I have a roles directory here and one role has a vars/main.yml file with the var I need to run my script and there is another file containing sensitive info call vault.yml (encrypted by ansible-vault). I would like to know how to use this vault.yml file. I first try to add it to main.yml using (include_vars: vault.yml) but it is not working (or I'm missing something)
dziendobry
I mean...I'm missing something for sure /o\
Hi I just bumped on this problem on my project, when I gather_facts, vars interpretation doesn't work anymore. This happends in ansible 2.4 and 2.8
I'd like to keep vars interpretation when activating fact gathering.
when gather_facts: no
TASK [debug] **********************************************************************************************************************************
ok: [test1-server] => (item={u'path': u'/tmp/somedir/a', u'name': u'some_name'}) => {
"msg": {
"name": "some_name",
"path": "/tmp/somedir/a"
}
when gather_facts: yes
TASK [debug] **********************************************************************************************************************************
ok: [test1-server] => (item={u'path': u'{{ dir_a }}', u'name': u'some_name'}) => {
"msg": {
"name": "some_name",
"path": "{{ dir_a }}"
}
}
Playbook:
- hosts: all
gather_facts: yes
vars:
type: "dirs"
dir_a: /tmp/somedir/a
dirs:
- name: "some_name"
path: "{{ dir_a }}"
tasks:
- name: debug
debug:
msg: "{{ item }}"
with_items:
- "{{ vars[type]}}"
type
:-)
Hi Jay, here those play vars doesn't end up in hostvars[inventory_hostname].
and yes type is a bad example for a variable
I am using vars[] to force the interpretation of a string into a variable, which is the problem I have in my actual project.
vars[dvars] => vars['dirs'] => [{ name: "dir_a", path: "/tmp/somedir/a"}]
To be more precise my question is: What is the approprate way to make ansible inteprete variable that referes to other variables, and/or values(string) that referes to variables ? Espacially in this kind of nested cases !
In this example dir_a is never interpreted through vars[dvar] (gather_facts value doesn't change anything)
- hosts: all
gather_facts: yes
vars:
dvar: "dirs"
dir_a: /tmp/somedir/a
dirs:
- name: "dir_a"
path: "{{ dir_a }}"
tasks:
- name: debug dvar
debug:
msg: "{{ dvar }}"
- name: debug dirs
debug:
msg: "{{ dirs }}"
- name: debug vars[dvar]
debug:
msg: "{{ vars[dvar] }}"
- name: debug hostvars[inventory_hostname][dvar]
debug:
msg: "{{ hostvars[inventory_hostname][dvar] }}"
TASK [debug dvar] ****************************************************************************************************************************************************************************
ok: [test1-server] => {
"msg": "dirs"
}
TASK [debug dirs] ****************************************************************************************************************************************************************************
ok: [test1-server] => {
"msg": [
{
"name": "dir_a",
"path": "/tmp/somedir/a"
}
]
}
TASK [debug vars[dvar]] **********************************************************************************************************************************************************************
ok: [test1-server] => {
"msg": [
{
"name": "dir_a",
"path": "{{ dir_a }}"
}
]
}
TASK [debug hostvars[inventory_hostname][dvar]] **********************************************************************************************************************************************
fatal: [test1-server]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute u'dirs'\
....
line 24, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: debug hostvars[inventory_hostname][dvar]\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no attribute u'dirs'"}
Things seems to work far away better with lookup('vars')...
available from 2.5
https://docs.ansible.com/ansible/latest/plugins/lookup/vars.html
Thanks anyway
- name: debug lookup('vars', dvar )
debug:
msg: "{{ lookup('vars', dvar )}}"
meta/main.yml
, vars/main.yml
, etc, so I wrote a tiny PR so you can write meta.yml
and vars.yml
. Here's nopdotcom/ansible#1. I ran some stats on all of Galaxy and of course there are huge numbers of redundant directories...
ansible-galaxy init
command to build out the structure for you.
.yaml
and .json
.