Ansible Permissions Issue
Read the manual.
A solution here is to use the 'executable' parameter for either the 'command' or 'shell' modules.
So I tried using the command module like so:
- name: install ruby 1.9.3
command: rvm install ruby-1.9.3-p448 executable=/bin/bash creates=/usr/local/rvm/bin/ruby-1.9.3-p448
ignore_error: true
But the playbook hung indefinitely. The manual states:
If you want to run a command through the shell (say you are using <, >, |, etc), you actually want the shell module instead. The command module is much more secure as it's not affected by the user's
environment.
So I tried using the shell module:
- name: install ruby 1.9.3
shell: rvm install ruby-1.9.3-p448 executable=/bin/bash creates=/usr/local/rvm/bin/ruby-1.9.3-p448
ignore_error: true
And it works!
ansible - playbook execution fails for user creation with permission issue
If you're not connecting to the remote host as root
, then you need to tell Ansible to become root
when running your tasks using the become:
key, which can be placed on a play to run all tasks in that play with elevated privileges:
hosts: all
become: true
tasks:
- name: Ansible create user example.
user:
name: vasanth
password: vasanth
Or it can be placed on individual tasks to run only those tasks with
elevated privileges:
hosts: all
tasks:
- name: Ansible create user example.
become: true
user:
name: vasanth
password: vasanth
The become
key isn't used exclusively for privilege escalation; it
can be used to ask Ansible to run as any user in combination with thebecome_user
key. You can read more in the docs.
Playbook failing execution due to permission denied
You have to be sure that the root user has executable permissions on the new OSM download. When you use a become: yes without become_user, the default user is root
So you need to be sure that root user can execute your script.
Try the get_url like that:
- hosts: osm
user: ubuntu
become: yes
tasks:
- name: Download the OSM installer
get_url:
url: https://osm-download.etsi.org/ftp/osm-8.0-eight/install_osm.sh
dest: /tmp/install_osm.sh
mode: "0555"
- name: Execute the OSM installer
shell: /tmp/install_osm.sh
Play with the mode param of the get_url module.
Ansible playbook - permission denied
I managed to pinpoint the problem. The setup.py file should never have been created in the home folder "/home/myuser" where root has no access.
I tried setting the environment variable TMPDIR and the variable "remote_tmp" in ansible.cfg as below.
ansible.cfg :
remote_tmp = /tmp/ansible-$USER
The problem was, I had missed to include the "[defaults]" "section header" before specifying the "remote_tmp" parameter. The below ansible.cfg file worked as expected.
ansible.cfg :
[defaults]
remote_tmp = /tmp/ansible-$USER
Related Topics
Set Preferred Listen Address in Weblogic 11G
How to Run a Binary File That Is Mach-O Executable I386 on Linux
Fork, Execlp and Kill. Zombie Process
Command Execution with Nohup in Background
How to Configure/Make/Install Against an Older Version of a Library
Centos Cgconfig Fails to Start
Bus Error Opening and Mmap'Ing a File
How to Have Chef Reload Global Path
Multi-Architectural Binary Rpm and The Noarch
How to Enable Spell Checker in Google Colab (Colab Operates on Linux Os)
Can't Run Dmidecode on Docker Container
Passing a Command with Arguments as a String to Docker Run
Get Apache Total CPU Usage in (Linux)
Linux Shared Library Depends on Symbols in Another Shared Library Opened by Dlopen with Rtld_Local
Why This Shell Won't Work If It's Called from Rc.Local But Ssh