I have a task that calls a root password from my vault.yml by adding it to
the task as:
vars:
ansible_become_pass:"{{ root }}"
However, I have to use it multiple times within my tasks/main.yml. Is is
possible to add that variable once to vars/main.yml
Here is what my tasks/main.yml looks like:
---
# tasks file for pb_install_test
- name: import vault file
include_vars: "vault.yml"
no_log: true
- name: install required nfs packages
yum: name={{ item }} state=present
with_items:
- nfs-utils
- nfs-utils-lib
- python-pip
- ksh
- name: create temporary pip directory
file: path=/tmp/pip_packages state=directory mode=0755
- name: copy pip pexpect packages and dependencies
copy: src={{ item }} dest=/tmp/pip_packages
with_items:
- ../../../../../files/pip_packages/pexpect-4.0.1.tar.gz
-
../../../../../files/pip_packages/ptyprocess-0.5.1-py2.py3-none-any.whl
- name: install pexpect using pip
command: /bin/bash -c "pip install pexpect --no-index
--find-links=file:///tmp/pip_packages/"
- name: mount nfs share
mount: name=/tmp/pb_install src="server.hostname.com:/dir/pb" fstype=nfs
opts="vers=3" state=mounted
- name: install pbis and pbul
shell: /bin/ksh "/tmp/pb_install/pbis_install" test_env
- name: join systems to domain and correct ou
become: yes
become_method: su
become_user: root
vars:
ansible_become_pass: "{{ root }}"
expect:
command: /bin/bash -c "/opt/pbis/bin/domainjoin-cli join --notimesync
--disable hostname --ou OU=servers,OU=linux,DC=domain,DC=host,DC=com
domain.server.com join_account"
responses:
user@server's password: "{{ user_account }}"
- name: remove /tmp/pip_packages directory
become: yes
become_method: su
become_user: root
vars:
ansible_become_pass: "{{ root }}"
file: path=/tmp/pip_packages state=absent
- name: unmount nfs share
become: yes
become_method: su
become_user: root
vars:
ansible_become_pass: "{{ root }}"
mount: name=/tmp/pb_install src="server.hostname.com:/dir/pb" fstype=nfs
state=unmounted
- name: remove nfs mount entry from fstab
become: yes
become_method: su
become_user: root
vars:
ansible_become_pass: "{{ root }}"
mount: name=/tmp/pb_install src="server.hostname.com:/dir/pb" fstype=nfs
state=absent
Keep in mind, the above works but I have a feeling I can probably have the
vars:\n ansible_become_pass: "{{ root }}" called once somewhere instead of
having to add it to my tasks/main.yml
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4911b334-e316-44dd-97ee-73d6c0de361f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.