What is remote_tmp in ansible used for? - ansible

I'm learning ansible config recently and encountered with this variable remote_tmp. What does the tmp folder do?
Does this folder hold all the ansible folder contents from my manage node?
Thanks

Ok, i'm gonna answer my question here. Ansible works by transferring modules to your remote machines, running them, and then cleaning up after itself. This setting allower user change the temp folder ansible is using on remote machine.

Related

Getting a python warning when running playbook EC2 inventory

I am really new to Ansible and I hate getting warnings when I run a playbook. This environment is being used for my education.
Environment:
AWS EC2
4 Ubuntu 20
3 Amazon Linux2 hosts
Inventory
using the dynamic inventory script
playbook
just runs a simple ping against all hosts. I wanted to test the inventory
warning
[WARNING]: Platform linux on host XXXXXX.amazonaws.com is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the
meaning of that path. See https://docs.ansible.com/ansible-core/2.11/reference_appendices/interpreter_discovery.html for more information.
Things I have tried
updated all sym links on hosts to point to the python3 version
adding the line "ansible_python_interpreter = /usr/bin/python" to "/etc/ansible/ansible.cfg"
I am relying on that cfg file
I would like to know how to solve this. since I am not running a static inventory, I didn't think that I could specific an interpreter on a per host or group of hosts. While the playbook runs, it seems that something is not configured correctly and I would like to get that sorted. This is only present on the Amazon Linux instances. the Ubuntu instances are fine.
Michael
Thank you. I did find another route that work though I am sure that you suggest would also work.
I was using the wrong configuration entry. I was using
ansible_python_interpreter = /usr/bin/python
when I should have been using
interpreter_python = /usr/bin/python
on each host I made sure that /usr/bin/python sym link was pointing and the correct version.
according to the documentation
for individual hosts and groups, use the ansible_python_interpreter inventory variable
globally, use the interpreter_python key in the [defaults] section of ansible.cfg
Regards, Michael.
You can edit your ansible.cfg and set auto_silent mode:
interpreter_python=auto_silent
Check reference here:
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html

.ansible/tmp/ansible-tmp-* Permission denied

Remote host throws error while running Ansible playbook despite a user being sudo user.
"/usr/bin/python: can't open file '/home/ludd/.ansible/tmp/ansible-tmp-1466162346.37-16304304631529/zypper'
A fix that worked for me, was to change the path of the ansible's remote_tmp directory, in ansible's configuration file, e.g.
# /etc/ansible/ansible.cfg
remote_tmp = /tmp/${USER}/ansible
Detailed information can be found here.
Note: With ansible v4 (or later) this this variable might look like this ansible_remote_tmp check the docs
Caution:Ansible Configuration Settings can be declared and used in a configuration file which will be searched for in the following order:
ANSIBLE_CONFIG (environment variable if set)
ansible.cfg (in the current directory)
~/.ansible.cfg (in the home directory)
/etc/ansible/ansible.cfg
I had to set variable ansible_remote_tmp rather than remote_tmp in order to make it working.
Changing remote_tmp didn't solve the issue for me. What did solve it, however, was removing --connection=local from the playbook invocation.
How does the file in question get to the host? Do you copy or sync it? If you do, may want do to do
chmod 775 fileName
on the file before you send it to the host.

Using Ansible for ScaleIO provisioning

I am using this playbook to install a 3 node ScaleIO cluster on CentOS 7.
https://github.com/sperreault/ansible-scaleio
In the EMC documentation they specify that a CSV file needs to be uploaded to the IM to complete installation, I am not sure though how I can automate that part within this playbook. Has anyone got any practical experience of doing so?
this playbook is used to install ScaleIO manually, not by IM.
so you do not need to prepare a csv file

How does the copy module understand where to check for src and dest directories?

This might not be a valid question. I was going through source of copy module at github.
While I could understand what and how it is doing one thing I am not able to get. I see following two lines
if not os.path.exists(src)
and
if os.path.exists(dest):
While I get that these lines are checking the presence of source and dest directories, how does python knows where to look these on as they are on different machines (the ansible server and host). How does python differentiates them and looks for them on their repective machines?
Can someone please help?
I think this copy module (liblary/file/copy) doesn't work.
Usually, when we use a command like this,
ansible webservers -m copy -a "src=/tmp/foo.conf dest=/tmp/bar.conf"
ansible will use this runnner module(lib/ansible/runner/action_plugins/copy.py) preferentially.
I tried running the same command, hiding the runner module. Then, (ansible/liblary/file/copy) module was executed. However, this did not do the work that is expected. There are several problems, this code is one of a cause.
if not os.path.exists(src)
if os.path.exists(dest):
Both check the file on the remote host.

How to change Jenkins default folder on Windows?

How to change Jenkins default folder on Windows where Jenkins runs as Windows service.
I want to change C:\Users\Coola\.jenkins folder to d:\Jenkins due to lack of space on C: partition (Every build takes ~10MB of free space). I don't want to reinstall Jenkins as Windows service. I just want to change folder of existing Jenkins instance. In case of lack of global solution I could focus only on relocating jobs folder.
Thanks in advance for your help.
Stop Jenkins service
Move C:\Users\Coola\.jenkins folder to d:\Jenkins
Using regedit, change HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Jenkins\ImagePath to "d:\Jenkins\jenkins.exe"
Start service
Apparently, grams' answer works but is not preferred. In Windows software and data/configuration files are supposed to reside in different places. This should be well known to Unix guys, it is basically like having a home directory. However, the wording with regard to JENKINS_HOME is broken anyways as setting an environment variable does not help despite what is being said in the help text.
I used the procedure that is described here: http://tech.nitoyon.com/en/blog/2014/02/25/jenkins-home-win/
Basically:
Stop Jenkins service
Edit entry <env name="JENKINS_HOME" value="%BASE%"/> in jenkins.xml in the Jenkins installation directory. This will be something like C:\Program Files (x86)\Jenkins. In your case value has to be set to d:\Jenkins
Move Files from the installation directory to the new destination, d:\Jenkins, all except (some of them may not exist in a fresh installation)
jre folder
jenkins.err.log
jenkins.exe
jenkins.exe.config
jenkins.out.log
jenkins.war
jenkins.war.bak
jenkins.war.tmp
jenkins.wrapper.log
jenkins.xml
Restart the service again.
When you read Administering Jenkins you can read all options how to modify the JENKINS_HOME environment variable.
On this website you can read how to configure you Tomcat container to override the JENKINS_HOME environment variable, they advise to create the file $CATALINA_BASE/conf/localhost/jenkins.xml, with the following content:
<Context docBase="../jenkins.war">
<Environment name="JENKINS_HOME" type="java.lang.String" value="/data/jenkins" override="true"/>
</Context>
Here is the answer that worked for me: Jenkins: How to change JENKINS_HOME on Windows
And in addition to grams answer, the most important part is creating an environment variable named JENKINS_HOME with value "D:\Jenkins". Without that, on starting Jenkins it would again create the .jenkins folder in your user home folder.
I was able to change the JENKINS_HOME variable following this http://tech.nitoyon.com/en/blog/2014/02/25/jenkins-home-win/
Setting JUST %JENKINS_HOME% as windows system wide environment variable didn't have any effect!
We installed by dropping the .war into Tomcat, and could set home by just setting the environment variable JENKINS_HOME (with a service restart).

Resources