text stringlengths 133 10k | labels stringlengths 71 6.5k |
|---|---|
How do I use sudo to redirect output to a location I don't have permission to write to? I've been given sudo access on one of our development RedHat linux boxes, and I seem to find myself quite often needing to redirect output to a location I don't normally have write access to. The trouble is, this contrived example doesn't work: sudo ls -hal /root/ > /root/test.out I just receive the response: -bash: /root/test.out: Permission denied How can I get this to work? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Quickly create a large file on a Linux system How can I quickly create a large file on a Linux ( Red Hat Linux ) system? dd will do the job, but reading from /dev/zero and writing to the drive can take a long time when you need a file several hundreds of GBs in size for testing... If you need to do that repeatedly, the time really adds up. I don't care about the contents of the file, I just want it to be created quickly. How can this be done? Using a sparse file won't work for this. I need the file to be allocated disk space. | O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to create a directory using Ansible How do you create a directory www at /srv on a Debian-based system using an Ansible playbook? | O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O B-PRODUCT O O |
Start ssh-agent on login I have a site as a remote Git repository pulling from Bitbucket using an SSH alias. I can manually start the ssh-agent on my server, but I have to do this every time I log in via SSH. I manually start the ssh-agent : eval ssh-agent $SHELL Then I add the agent: ssh-add ~/.ssh/bitbucket_id Then it shows up when I do: ssh-add -l And I'm good to go. Is there a way to automate this process, so I don't have to do it every time I log in? The server is running Red Hat 6.2 (Santiago). | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT B-VERSION I-VERSION I-VERSION O O O O |
Using env variable in Spring Boot's application.properties We are working on a Spring Boot web application, and the database we are using is MySQL; the setup we have is we first test it locally (means we need to install MySQL on our PC); then we push to Bitbucket; Jenkins automatically detects the new push to Bitbucket and does a build on it (for Jenkins mvn build to pass we also need to install MySQL on the virtual machines that is running Jenkins). if Jenkins build passes we push the code to our application on OpenShift (using the Openshift deployment plugin on Jenkins). The problem we have, as you may have already figured it out, is that: in application.properties we can not hard code the MySQL info. Since our project will be running in 3 different places ( local , Jenkins , and OpenShift ), we need to make the datasource field dynamic in application.properties (we know there are different ways of doing it but we are working on this solution for now). spring.datasource.url = spring.datasource.username = spring.datasource.password = The solution we came up with is we create system environment variables locally and in the Jenkins VM (naming them the same way OpenShift names them), and assigning them the right values respectively: export OPENSHIFT_MYSQL_DB_HOST="jdbc:mysql://localhost" export OPENSHIFT_MYSQL_DB_PORT="3306" export OPENSHIFT_MYSQL_DB_USERNAME="root" export OPENSHIFT_MYSQL_DB_PASSWORD="123asd" We have done this and it works. We have also checked with Map<String, String> env = System.getenv(); that the environment variables can be made into java variables as such: String password = env.get("OPENSHIFT_MYSQL_DB_PASSWORD"); String userName = env.get("OPENSHIFT_MYSQL_DB_USERNAME"); String sqlURL = env.get("OPENSHIFT_MYSQL_DB_HOST"); String sqlPort = env.get("OPENSHIFT_MYSQL_DB_PORT"); Now the only thing left is we need to use these java variables in our application.properties , and that is what we are having trouble with. In which folder, and how, do we need to assign the password , userName , sqlURL , and sqlPort variables for application.properties to be able to see them and how do we include them in application.properties ? We have tried many things one of them being: spring.datasource.url = ${sqlURL}:${sqlPort}/"nameofDB" spring.datasource.username = ${userName} spring.datasource.password = ${password} No luck so far. We are probably not putting these environment variables in the right class/folder or are using them incorrectly in application.properties . | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O B-PRODUCT O O O O O B-PRODUCT O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How can I list the contents of a package using YUM? I know how to use rpm to list the contents of a package ( rpm -qpil package.rpm ). However, this requires knowing the location of the .rpm file on the filesystem. A more elegant solution would be to use the package manager, which in my case is YUM . How can YUM be used to achieve this? | O O O O O O O O O O B-PRODUCT O O O O O O B-PRODUCT O O O O O O O O B-PRODUCT O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O B-PRODUCT O O O O O O |
Hadoop "Unable to load native-hadoop library for your platform" warning I'm currently configuring hadoop on a server running CentOs . When I run start-dfs.sh or stop-dfs.sh , I get the following error: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable I'm running Hadoop 2.2.0. Doing a search online brought up this link: [URL] However, the contents of /native/ directory on hadoop 2.x appear to be different so I am not sure what to do. I've also added these two environment variables in hadoop-env.sh : export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=/usr/local/hadoop/lib/" export HADOOP_COMMON_LIB_NATIVE_DIR="/usr/local/hadoop/lib/native/" Any ideas? | O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to redirect output of systemd service to a file I am trying to redirect output of a systemd service to a file but it doesn't seem to work: [Unit] Description=customprocess After=network.target [Service] Type=forking ExecStart=/usr/local/bin/binary1 agent -config-dir /etc/sample.d/server StandardOutput=/var/log1.log StandardError=/var/log2.log Restart=always [Install] WantedBy=multi-user.target Please correct my approach. | O O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to set JAVA_HOME in Linux for all users I am new to Linux system and there seem to be too many Java folders. java -version gives me: java version "1.7.0_55" OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode) When I am trying to build a Maven project , I am getting error: Error: JAVA_HOME is not defined correctly. We cannot execute /usr/java/jdk1.7.0_05/bin/java Could you please tell me which files I need to modify for root as well as not-root user and where exactly is java located? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O B-PRODUCT O O O B-PRODUCT O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O B-PRODUCT O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How can I pass variable to ansible playbook in the command line? How can one pass variable to ansible playbook in the command line? The following command didn't work: $ ansible-playbook -i '10.0.0.1,' yada-yada.yml --tags 'loaddata' django_fixtures="tile_colors" Where django_fixtures is my variable. | O O O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to preserve line breaks when storing command output to a variable? I’m using bash shell on Linux. I have this simple script ... #!/bin/bash TEMP=sed -n '/'"Starting deployment of"'/,/'"Failed to start context"'/p' "/usr/java/jboss/standalone/log/server.log" | tac | awk '/'"Starting deployment of"'/ {print;exit} 1' | tac echo $TEMP However, when I run this script ./temp.sh all the output is printed without the carriage returns/new lines. Not sure if its the way I’m storing the output to $TEMP, or the echo command itself. How do I store the output of the command to a variable and preserve the line breaks/carriage returns? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Specify sudo password for Ansible How do I specify a sudo password for Ansible in non-interactive way? I'm running Ansible playbook like this: $ ansible-playbook playbook.yml -i inventory.ini \ --user=username --ask-sudo-pass But I want to run it like this: $ ansible-playbook playbook.yml -i inventory.ini \ --user=username` **--sudo-pass=12345** Is there a way? I want to automate my project deployment as much as possible. | O O O O B-PRODUCT O O O O O O O O B-PRODUCT O O O O O O O O O O B-PRODUCT O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Run command on the Ansible host Is it possible to run commands on the Ansible controller node? My scenario is that I want to take a checkout from a git server that is hosted internally (and isn't accessible outside the company firewall). Then I want to upload the checkout (tarballed) to the production server (hosted externally). At the moment, I'm looking at running a script that does the checkout, tarballs it, and then runs the deployment script - but if I could integrate this into Ansible that would be preferable. | O O O O B-PRODUCT O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O |
Safely limiting Ansible playbooks to a single machine? I'm using Ansible for some simple user management tasks with a small group of computers. Currently, I have my playbooks set to hosts: all and my hosts file is just a single group with all machines listed: # file: hosts [office] imac-1.local imac-2.local imac-3.local I've found myself frequently having to target a single machine. The ansible-playbook command can limit plays like this: ansible-playbook --limit imac-2.local user.yml But that seems kind of fragile, especially for a potentially destructive playbook. Leaving out the limit flag means the playbook would be run everywhere. Since these tools only get used occasionally, it seems worth taking steps to foolproof playback so we don't accidentally nuke something months from now. Is there a best practice for limiting playbook runs to a single machine? Ideally the playbooks should be harmless if some important detail was left out. | O O B-PRODUCT O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How can I automatically redirect HTTP to HTTPS on Apache servers? I am trying to set up automatic redirection from HTTP to HTTPS: From manage.mydomain.com --- To ---> [URL] I have tried adding the following to my httpd.conf file, but it didn't work: RewriteEngine on ReWriteCond %{SERVER_PORT} !^443$ RewriteRule ^/(.*) [URL] [NC,R,L] How can I fix it? Environment: CentOS with Apache | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O |
How to move/rename a file using an Ansible task on a remote system How is it possible to move/rename a file/directory using an Ansible module on a remote system? I don't want to use the command/shell tasks and I don't want to copy the file from the local system to the remote system. | O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to install latest version of git on CentOS 8.x/7.x/6.x I used the usual: yum install git It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS such as CentOS 7. | O O O O O O O O B-VERSION I-VERSION O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O B-VERSION I-VERSION O O O O O O O O O O O O B-VERSION I-VERSION O O O O O O O O O O B-PRODUCT O O B-VERSION I-VERSION O |
How to run only one task in ansible playbook? Is there a way to only run one task in ansible playbook? For example, in roles/hadoop_primary/tasks/hadoop_master.yml . I have "start hadoop job tracker services" task. Can I just run that one task? hadoop_master.yml file: # Playbook for Hadoop master servers - name: Install the namenode and jobtracker packages apt: name={{item}} force=yes state=latest with_items: - hadoop-0.20-mapreduce-jobtracker - hadoop-hdfs-namenode - hadoop-doc - hue-plugins - name: start hadoop jobtracker services service: name=hadoop-0.20-mapreduce-jobtracker state=started tags: debug | O O O O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O O O |
How to ignore ansible SSH authenticity checking? Is there a way to ignore the SSH authenticity checking made by Ansible? For example when I've just setup a new server I have to answer yes to this question: GATHERING FACTS *************************************************************** The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established. RSA key fingerprint is xx:yy:zz:.... Are you sure you want to continue connecting (yes/no)? I know that this is generally a bad idea but I'm incorporating this in a script that first creates a new virtual server at my cloud provider and then automatically calls my ansible playbook to configure it. I want to avoid any human intervention in the middle of the script execution. | O O O B-PRODUCT O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O |
How to automatically add user account AND password with a Bash script? I need to have the ability to create user accounts on my Linux (Fedora 10) and automatically assign a password via a bash script(or otherwise, if need be). It's easy to create the user via Bash e.g.: [whoever@server ]# /usr/sbin/useradd newuser Is it possible to assign a password in Bash, something functionally similar to this, but automatically: [whoever@server ]# passwd newuser Changing password for user testpass. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully. [whoever@server ]# | O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How do you scroll up/down on the console of a Linux VM I recognize that Up / Down will give you the command history. But, how do you look at past output by scrolling up and down? I have used Shift + Page Up / Page Down , Alt + Shift + Up / Down and Page Up / Page Down but none of these seem to work. It is a Redhat Linux box. | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT O O |
Ansible: How to delete files and folders inside a directory? The below code only deletes the first file it gets inside the web dir. I want to remove all the files and folders inside the web directory and retain the web directory. How can I do that? - name: remove web dir contents file: path='/home/mydata/web/{{ item }}' state=absent with_fileglob: - /home/mydata/web/* Note: I've tried rm -rf using command and shell, but they don't work. Perhaps I am using them wrongly. Any help in the right direction will be appreciated. I am using ansible 2.1.0.0 | B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O |
How can I debug "ImagePullBackOff"? All of a sudden, I cannot deploy some images which could be deployed before. I got the following pod status: [root@webdev2 origin]# oc get pods NAME READY STATUS RESTARTS AGE arix-3-yjq9w 0/1 ImagePullBackOff 0 10m docker-registry-2-vqstm 1/1 Running 0 2d router-1-kvjxq 1/1 Running 0 2d The application just won't start. The pod is not trying to run the container. From the Event page, I have got Back-off pulling image "172.30.84.25:5000/default/arix@sha256:d326 . I have verified that I can pull the image with the tag with docker pull . I have also checked the log of the last container. It was closed for some reason. I think the pod should at least try to restart it. I have run out of ideas to debug the issues. What can I check more? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How can I permanently export a variable in Linux? I am running RHEL 6, and I have exported an environment variable like this: export DISPLAY=:0 That variable is lost when the terminal is closed. How do I permanently add this so that this variable value always exists with a particular user? | O O O O O O O O O O O O O B-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to specify more spaces for the delimiter using cut? Is there a way to specify multiple spaces as a field delimiter with the cut command (something like a " "+ regex)? For example, what field delimiter I should specify for the following string to reach value 3744 ? $ps axu | grep jboss jboss 2574 0.0 0.0 3744 1092 ? S Aug17 0:00 /bin/sh /usr/java/jboss/bin/run.sh -c example.com -b 0.0.0.0 cut -d' ' is not what I want, because it's only for a single space. awk is not what I am looking for either, so how to do this with cut ? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT B-PRODUCT O B-VERSION I-VERSION I-VERSION B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O B-VERSION I-VERSION B-VERSION I-VERSION B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to check if a file exists in Ansible? I have to check whether a file exists in /etc/ . If the file exists then I have to skip the task. Here is the code I am using: - name: checking the file exists command: touch file.txt when: $(! -s /etc/file.txt) | O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
What's the difference between defaults and vars in an Ansible role? When creating a new Ansible role, the template creates both a vars and a defaults directory with an empty main.yml file. When defining my role, I can place variable definitions in either of these, and they will be available in my tasks. What's the difference between putting the definitions into defaults and vars ? What should go into defaults , and what should to into vars ? Does it make sense to use both for the same data? I know that there's a difference in precedence/priority between the two, but I would like to understand what should go where. Let's say that my role would create a list of directories on the target system. I would like to provide a list of default directories to be created, but would like to allow the user to override them when using the role. Here's what this would look like: --- - directories: - foo - bar - baz I could place this either into the defaults/main.yml or in the vars/main.yml , from an execution perspective, it wouldn't make any difference - but where should it go? | O O O O O O O O O O O B-PRODUCT O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How do I install g++ for Fedora? How do I install g++ for Fedora Linux? I have been searching the dnf command to install g++ but didn't find anything. How do I install it? I have already installed gcc | O O O O O O O O B-PRODUCT O O O O O O O O O B-PRODUCT O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O |
Is there an alternative sleep function in C to milliseconds? I have some source code that was compiled on Windows. I am converting it to run on Red Hat Linux. The source code has included the <windows.h> header file and the programmer has used the Sleep() function to wait for a period of milliseconds. This won't work on the Linux. However, I can use the sleep(seconds) function, but that uses integer in seconds. I don't want to convert milliseconds to seconds. Is there a alternative sleep function that I can use with gcc compiling on Linux? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
ansible: lineinfile for several lines? The same way there is a module lineinfile to add one line in a file, is there a way to add several lines? I do not want to use a template because you have to provide the whole file. I just want to add something to an existing file without necessarily knowing what the file already contains so a template is not an option. | B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to do multiline shell script in Ansible right now I am using a shell script in ansible that would be much more readable if it was on multiple lines - name: iterate user groups shell: groupmod -o -g {{ item['guid'] }} {{ item['username'] }} ....more stuff to do with_items: "{{ users }}" Just not sure how to allow multiline script in Ansible shell module | O O O O O O O B-PRODUCT O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O |
Ansible fails with /bin/sh: 1: /usr/bin/python: not found I'm running into an error I've never seen before. Here is the command and the error: $ ansible-playbook create_api.yml PLAY [straw] ****************************************************************** GATHERING FACTS *************************************************************** failed: [104.55.47.224] => {"failed": true, "parsed": false} /bin/sh: 1: /usr/bin/python: not found TASK: [typical | install required system packages] ***************************** FATAL: no hosts matched or all hosts have already failed -- aborting PLAY RECAP ******************************************************************** to retry, use: --limit @/Users/john/create_api.retry 104.55.47.224 : ok=0 changed=0 unreachable=0 failed=1 Here is the create_api.yml file: --- - hosts: api remote_user: root roles: - api And here is the hosts file: [api] 104.55.47.224 I can remove the roles section and it won't make it to the first TASK, it will instead make it will only make it to the line /bin/sh: 1: /usr/bin/python: not found . What could be going on here? NOTE: In case anyone is pinging the IP address and failing to get a response, you should know I've changed the IP address since pasting code. EDIT python was installed locally, the problem was that it was not installed on the remote machine, which was running Ubuntu 15.04 | B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION |
Android Debug Bridge (adb) device - no permissions I have a problem connecting HTC Wildfire A3333 in debugging mode with my Fedora Linux 17. Adb says: ./adb devices List of devices attached ???????????? no permissions my udev rules (first rule for Samsung which works just fine and second for HTC which is not): SUBSYSTEM=="usb",SYSFS{idVendor}=="04e8",SYMLINK+="android_adb",MODE="0666",GROUP="plugdev" SUBSYSTEM=="usb",SYSFS{idVendor}=="0bb4",SYMLINK+="android_adb",MODE="0666",GROUP="plugdev" For Samsung devices everything's okay: ./adb devices List of devices attached 00198a9422618e device I have been trying all of the answers given in a simmilar thread wthout any luck: Using HTC wildfire for android development | O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to switch a user per task or set of tasks? A recurring theme that's in my ansible playbooks is that I often must execute a command with sudo privileges ( sudo: yes ) because I'd like to do it for a certain user. Ideally I'd much rather use sudo to switch to that user and execute the commands normally. Because then I won't have to do my usual post commands clean up such as chowning directories. Here's a snippet from one of my playbooks: - name: checkout repo git: repo=[URL] version=master dest={{ dst }} sudo: yes - name: change perms file: dest={{ dst }} state=directory mode=0755 owner=some_user sudo: yes Ideally I could run commands or sets of commands as a different user even if it requires sudo to su to that user. | O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Where can I get a list of Ansible pre-defined variables? I see that Ansible provide some pre-defined variables that we can use in playbooks and template files. For example, the host IP address is ansible_eth0.ipv4.address . Googleing and searching the docs I couldn't find a list of all available variables. Would someone list them for me? | O O O O O O O B-PRODUCT O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to get the host name of the current machine as defined in the Ansible hosts file? I'm setting up an Ansible playbook to set up a couple servers. There are a couple of tasks that I only want to run if the current host is my local dev host, named "local" in my hosts file. How can I do this? I can't find it anywhere in the documentation. I've tried this when statement, but it fails because ansible_hostname resolves to the host name generated when the machine is created, not the one you define in your hosts file. - name: Install this only for local dev machine pip: name: pyramid when: ansible_hostname == "local" | O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O |
Determining the path that a yum package installed to I've installed ffmpeg using yum under Redhat, and I'm having difficulty figuring out where (what path) it installed the package to. Is there an easy way of determining this without resorting to finding it myself manually? | O O O O O B-PRODUCT O O O O O O O O O B-PRODUCT O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName I tried to restart my Apache server on CentOS 5.0 and got this message: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName Here is the /etc/hosts file: 127.0.0.1 server4-245 server4-245.com localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 Here is the /etc/sysconfig/network file: NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=server4-245 I also have this in the Apache httpd.conf file: ServerName localhost However, I still get the first error message when I restart Apache. | O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O B-VERSION B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to run a task when variable is undefined in ansible? I am looking for a way to perform a task when Ansible variable is not registers or undefined. E.g.: - name: some task command: sed -n '5p' "{{app.dirs.includes}}/BUILD.info" | awk '{print $2}' when: (! deployed_revision) AND ( !deployed_revision.stdout ) register: deployed_revision | O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
CentOS 64 bit bad ELF interpreter I have just installed CentOS 6 64bit version, I'm trying to install a 32-bit application on a 64-bit machine and got this error: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory How do I resolve this? | B-VERSION I-VERSION O O O O O O O O B-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
What's the easy way to auto create non existing dir in ansible In my Ansible playbook many times i need to create a file: - name: Copy file template: src: code.conf.j2 dest: "{{ project_root }}/conf/code.conf" Many times conf dir is not there. Then I have to create another task to create that dir first. Is there any easy way to auto create the dir if it doesn't exist with some option? | O O O O O O O O O O O O O B-PRODUCT O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Ansible: get current target host's IP address How do you get the current host's IP address in a role? I know you can get the list of groups the host is a member of and the hostname of the host but I am unable to find a solution to getting the IP address. You can get the hostname by using {{inventory_hostname}} and the group by using {{group_names}} I have tried things like {{ hostvars[{{ inventory_hostname }}]['ansible_ssh_host'] }} and ip="{{ hostvars.{{ inventory_hostname }}.ansible_ssh_host }}" | B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O B-PRODUCT O O O |
Variable that has the path to the current ansible-playbook that is executing? Is there an Ansible variable that has the absolute path to the current playbook that is executing? Some context: I'm running/creating an Ansible script against localhost to configure a MySQL Docker container and wanting to mount the data volume relative to the Ansible playbook. For example, let's say I've checkout a repository to ~/branch1/ and then I run ansible-playbook dev.yml I was thinking it should save the volume to ~/branch1/.docker_volume/ . If I ran it from ~/branch2 then it should configure the volume to ~/branch2/.docker_volume/ . | O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to make rpm auto install dependencies I have built two RPM packages proj1-1.0-1.x86_64.rpm libtest1-1.0-1.x86_64.rpm proj1 depends on the file libtest1.so being present and it is reflected correctly in the RPM packages as seen here: user@my-pc:~$ rpm -qp --requires proj1-1.0-1.x86_64.rpm libtest1.so()(64bit) user@my-pc:~$ rpm -qp --provides libtest1-1.0-1.x86_64.rpm libtest1.so()(64bit) The installation of proj1 fails due to a missing dependency. user@my-pc:~$ rpm -ivh proj1-1.0-1.x86_64.rpm error: Failed dependencies: libtest1.so()(64bit) is needed by proj1-1.0-1.x86_64.rpm How do I ensure that libtest1-1.0-1.x86_64.rpm is installed automatically during the installation of proj1-1.0-1.x86_64.rpm ? I did try the --aid option with rpm -i as described here but it didn't work for me. Is there any other way? Thanks for any help. | O O O B-PRODUCT O O O O O O O B-PRODUCT O O O B-VERSION I-VERSION I-VERSION O O O O O B-PRODUCT O O B-VERSION I-VERSION I-VERSION O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O B-PRODUCT O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O B-PRODUCT O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O B-VERSION I-VERSION I-VERSION O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O B-PRODUCT O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O B-PRODUCT O O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O B-PRODUCT O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O |
How to automatically install Ansible Galaxy roles? All my Ansible playbooks/roles are checked in to my git repo. However, for Ansible Galaxy roles I always have to explicitly download them one by one on every machine I want to run Ansible from. It's even tough to know in advance exactly which Ansible Galaxy roles are needed until Ansible complains about a missing role at runtime. How is one supposed to manage the Ansible Galaxy role dependencies? I would like to either have them checked into my git repo along with the rest of my ansible code or have them automatically be identified and downloaded when I run Ansible on a new machine. | O O O O B-PRODUCT O O O O O B-PRODUCT O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O B-PRODUCT O O O O O B-PRODUCT O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT O O O O O |
How to set host_key_checking=false in ansible inventory file? I would like to use ansible-playbook command instead of ' vagrant provision '. However setting host_key_checking=false in the hosts file does not seem to work. # hosts file vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key ansible_ssh_user=vagrant ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1 host_key_checking=false Is there a configuration variable outside of Vagrantfile that can override this value? Also, how would this work if running ansible from a Kubernetes pod? | O O O O O O O B-PRODUCT O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O B-PRODUCT O O B-PRODUCT O O B-PRODUCT O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O |
How to set Linux environment variables with Ansible Hi I am trying to find out how to set environment variable with Ansible. something that a simple shell command like this: EXPORT LC_ALL=C tried as shell command and got an error tried using the environment module and nothing happend. what am I missing | O O O O O O O B-PRODUCT O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Where is the php.ini file on a Linux/CentOS PC? I can't find PHP.ini location on my server. I've checked all Stack Overflow answers but I can't find my php.ini location. I have Linux, Cent OS, zPanel. Last version of PHP. My computer: Linux Mint 15 KDE. | O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Specifying ssh key in ansible playbook file Ansible playbook can specify the key used for ssh connection using --key-file on the command line. ansible-playbook -i hosts playbook.yml --key-file "~/.ssh/mykey.pem" Is it possible to specify the location of this key in playbook file instead of using --key-file on command line? Because I want to write the location of this key into a var.yaml file, which will be read by ansible playbook with vars_files: . The followings are parts of my configuration: vars.yml file key1: ~/.ssh/mykey1.pem key2: ~/.ssh/mykey2.pem playbook.yml file --- - hosts: myHost remote_user: ubuntu key_file: {{ key1 }} # This is not a valid syntax in ansible. Does there exist this kind of directive which allows me to specify the ssh key used for this connection? vars_files: - vars.yml tasks: - name: Echo a hello message command: echo hello I've tried adding ansible_ssh_private_key_file under vars . But it doesn't work on my machine. vars_files: - vars.yml vars: ansible_ssh_private_key_file: "{{ key1 }}" tasks: - name: Echo a hello message command: echo hello If I run ansible-playbook with the playbook.yml above. I got the following error: TASK [Gathering Facts] ****************************************************************************************************************************** Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/system/setup.py <192.168.5.100> ESTABLISH SSH CONNECTION FOR USER: ubuntu <192.168.5.100> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/myName/.ansible/cp/2d18691789 192.168.5.100 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"'' <192.168.5.100> (255, '', 'Permission denied (publickey).\r\n') fatal: [192.168.5.100]: UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey).\r\n", "unreachable": true } to retry, use: --limit @/Users/myName/playbook.retry I don't find the name of my key file in the ssh command. It's strange. | O O O O B-PRODUCT O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How do you stop Ansible from creating .retry files in the home directory? When Ansible has problems running plays against a host, it will output the name of the host into a file in the user's home directory ending in '.retry'. These are often not used and just cause clutter, is there a way to turn them off or put them in a different directory? | O O O O B-PRODUCT O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
What is the difference between persistent volume (PV) and persistent volume claim (PVC) in simple terms? What is the difference between persistent volume (PV) and persistent volume claim (PVC) in Kubernetes/ Openshift by referring to documentation? What is the difference between both in simple terms? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O |
How can I find the version of the Fedora I use? sudo find /etc | xargs grep -i fedora > searchFedora gives: /etc/netplug.d/netplug: # At least on Fedora Core 1 ... But see the Fedora version in the /etc/netplug.d/netplug file. Is it serious? | O O O O O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O |
Override hosts variable of Ansible playbook from the command line This is a fragment of a playbook that I'm using ( server.yml ): - name: Determine Remote User hosts: web gather_facts: false roles: - { role: remote-user, tags: [remote-user, always] } My hosts file has different groups of servers, e.g. [web] x.x.x.x [droplets] x.x.x.x Now I want to execute ansible-playbook -i hosts/<env> server.yml and override hosts: web from server.yml to run this playbook for [droplets] . Can I just override as a one time off thing, without editing server.yml directly? Thanks. | O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to create an empty file with Ansible? What is the easiest way to create an empty file using Ansible? I know I can save an empty file into the files directory and then copy it to the remote host, but I find that somewhat unsatisfactory. Another way is to touch a file on the remote host: - name: create fake 'nologin' shell file: path=/etc/nologin state=touch owner=root group=sys mode=0555 But then the file gets touched every time, showing up as a yellow line in the log, which is also unsatisfactory... Is there any better solution to this simple problem? | O O O O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
rhc setup gives error no such file dl/import I'm installing openshift client tools as described: [URL] . On step 'Setting up Your Machine' I got error: rhc setup C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' : cannot load such file -- dl/import (LoadError) Full stack trace: C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- dl/import (LoadError) from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:1:in <top (required)>' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:5:in <top (required)>' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent.rb:22:in <top (required)>' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/key_manager.rb:4:in <top (required)>' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:4:in <top (required)>' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.2/lib/net/ssh.rb:11:in <top (required)>' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/ssh_helpers.rb:18:in <top (required)>' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/wizard.rb:77:in <class:Wizard>' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/wizard.rb:7:in <module:RHC>' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/wizard.rb:6:in <top (required)>' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/commands/base.rb:4:in <top (required)>' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/commands/account.rb:2:in <module:Commands>' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/commands/account.rb:1:in <top (required)>' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/commands.rb:189:in block in load' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/commands.rb:188:in each' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/commands.rb:188:in load' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/lib/rhc/cli.rb:36:in start' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rhc-1.35.1/bin/rhc:20:in <top (required)>' from C:/Ruby22-x64/bin/rhc:23:in load' from C:/Ruby22-x64/bin/rhc:23:in `<main>' I found same problem: [URL] It's suggest to replace DL with Fiddle. How I can get working rhc? | O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Installing Python 3 on RHEL I'm trying to install python3 on RHEL using the following steps: yum search python3 Which returned No matches found for: python3 Followed by: yum search python None of the search results contained python3. What should I try next? | O O O O B-PRODUCT O O O O O O O O B-PRODUCT O O O O O B-PRODUCT O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O |
Copy multiple files with Ansible How can I copy more than a single file into remote nodes by Ansible in a task? I've tried to duplicate the copy module line in my task to define files but it only copies the first file. | O O O O B-PRODUCT O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Write variable to a file in Ansible I am pulling JSON via the URI module and want to write the received content out to a file. I am able to get the content and output it to the debugger so I know the content has been received, but I do not know the best practice for writing files. | O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Ansible: Can I execute role from command line? Suppose I have a role called "apache" Now I want to execute that role on host 192.168.0.10 from the command line from Ansible host ansible-playbook -i "192.168.0.10" --role "path to role" Is there a way to do that? | B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O B-PRODUCT O B-PRODUCT I-PRODUCT I-PRODUCT O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O |
How can I find out the total physical memory (RAM) of my Linux box suitable to be parsed by a shell script? I'm creating a shell script to find out the total physical memory in some RHEL Linux boxes. First of all I want to stress that I'm interested in the total physical memory recognized by the kernel, not just the available memory . Therefore, please, avoid answers suggesting to read /proc/meminfo or to use the free , top or sar commands -- In all these cases, their " total memory " values mean " available memory " ones. The first thought was to read the boot kernel messages: Memory: 61861540k/63438844k available (2577k kernel code, 1042516k reserved, 1305k data, 212k init) But in some Linux boxes, due to the use of EMC2's PowerPath software and its flooding boot messages in the kernel startup, that useful boot kernel message is not available, not even in the /var/log/dmesg file. The second option was the dmidecode command (I'm warned against the possible mismatch of kernel recognized RAM and real RAM due to the limitations of some older kernels and architectures). The option --memory simplifies the script but I realized that older releases of that command have no --memory option. My last chance was the getconf command. It reports the memory page size, but not the total number of physical pages -- the _PHYS_PAGES system variable seems to be the available physical pages, not the total physical pages. # getconf -a | grep PAGES PAGESIZE 4096 _AVPHYS_PAGES 1049978 _PHYS_PAGES 15466409 My question: Is there another way to get the total amount of physical memory, suitable to be parsed by a shell script? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Ansible Playbooks vs Roles According to the Ansible docs, a Playbook is: ...the basis for a really simple configuration management and multi-machine deployment system, unlike any that already exist, and one that is very well suited to deploying complex applications. And, again, according to those same docs, a Role are: ...ways of automatically loading certain vars_files, tasks, and handlers based on a known file structure. Grouping content by roles also allows easy sharing of roles with other users. However the distinction between these and their different use cases is not immediately obvious to me. For instance, if I configure my /etc/ansible/hosts file to look like: [databases] mydb01.example.org mydb02.example.org [mail_servers] mymail01.example.org mymail_dr.example.org ...then what is this " [databases] " entry...a role ? Or the name of a playbook YAML file somewhere? Or something else?!? If someone could explain to me the differences on these, my understanding of Ansible would be greatly enhance! Playbook vs Role vs [databases] and similar entries in /etc/ansible/hosts If Playbooks are defined inside of YAML files, then where are Roles defined? Aside from the ansible.cfg living on the Ansible server, how do I add/configure Ansible with available Playbooks/Roles? For instance, when I run ansible-playbook someplaybook.yaml , how does Ansible know where to find that playbook? | B-PRODUCT O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O B-PRODUCT O O O O O O O O B-PRODUCT O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O B-PRODUCT O O O O O O O |
Best practice to run Linux service as a different user Services default to starting as root at boot time on my RHEL box. If I recall correctly, the same is true for other Linux distros which use the init scripts in /etc/init.d . What do you think is the best way to instead have the processes run as a (static) user of my choosing? The only method I'd arrived at was to use something like: su my_user -c 'daemon my_cmd &>/dev/null &' But this seems a bit untidy... Is there some bit of magic tucked away that provides an easy mechanism to automatically start services as other, non-root users? EDIT: I should have said that the processes I'm starting in this instance are either Python scripts or Java programs. I'd rather not write a native wrapper around them, so unfortunately I'm unable to call setuid() as Black suggests. | O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Ansible: Store command's stdout in new variable? Inside my playbook I'd like to create a variable holding the output of an external command. Afterwards I want to make use of that variable in a couple of templates. Here are the relevant parts of the playbook: tasks: - name: Create variable from command command: "echo Hello" register: command_output - debug: msg="{{command_output.stdout}}" - name: Copy test service template: src=../templates/test.service.j2 dest=/tmp/test.service - name: Enable test service shell: systemctl enable /tmp/test.service - name: Start test service shell: systemctl start test.service and let's say this is my template: [Unit] Description=MyApp After=docker.service Requires=docker.service [Service] TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker kill busybox1 ExecStartPre=-/usr/bin/docker rm busybox1 ExecStartPre=/usr/bin/docker pull busybox ExecStart=/usr/bin/docker run --name busybox1 busybox /bin/sh -c "while true; do echo {{ string_to_echo }}; sleep 1; done" [Install] WantedBy=multi-user.target (Notice the {{ string_to_echo }} ) So what I'm basically looking for is a way to store the contents of command_output.stdout (which is generated/retrieved during the first task) in a new variable string_to_echo . That variable I'd like to use in multiple templates afterwards. I guess I could just use {{command_output.stdout}} in my templates, but I want to get rid of that .stdout for readability. | B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Ansible: Set variable to file content I'm using the ec2 module with ansible-playbook I want to set a variable to the contents of a file. Here's how I'm currently doing it. Var with the filename shell task to cat the file use the result of the cat to pass to the ec2 module. Example contents of my playbook. vars: amazon_linux_ami: "ami-fb8e9292" user_data_file: "base-ami-userdata.sh" tasks: - name: user_data_contents shell: 'cat {{ user_data_file }}' register: user_data_action - name: launch ec2-instance local_action: ... user_data: '{{ user_data_action.stdout }}' I assume there's a much easier way to do this, but I couldn't find it while searching Ansible docs. | B-PRODUCT O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O |
Creating a new user and password with Ansible I have an ansible task which creates a new user on ubuntu 12.04; - name: Add deployment user action: user name=deployer password=mypassword it completes as expected but when I login as that user and try to sudo with the password I set it always says it's incorrect. What am I doing wrong? | O O O O O O O B-PRODUCT O O O B-PRODUCT O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Two versions of python on linux. how to make 2.7 the default I've got two versions of python on my linuxbox: $python Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> $ /usr/local/bin/python2.7 Python 2.7.3 (default, Oct 8 2013, 15:53:09) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> $ which python /usr/bin/python $ ls -al /usr/bin/python -rwxr-xr-x. 2 root root 4864 Jul 10 22:49 /usr/bin/python How can I make 2.7 be the default version so when I type python it puts me in 2.7? | O O O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O B-PRODUCT I-PRODUCT B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O B-PRODUCT I-PRODUCT B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION O |
Run task only if host does not belong to a group I'd like to able to run an ansible task only if the host of the current playbook does not belong to a certain group. In semi pseudo code: - name: my command command: echo stuff when: "if {{ ansible_hostname }} not in {{ ansible_current_groups }}" How should I do this? | O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O B-PRODUCT O O O O O O O O O |
Python subprocess.Popen "OSError: [Errno 12] Cannot allocate memory" Note: This question was originally asked here but the bounty time expired even though an acceptable answer was not actually found. I am re-asking this question including all details provided in the original question. A python script is running a set of class functions every 60 seconds using the sched module: # sc is a sched.scheduler instance sc.enter(60, 1, self.doChecks, (sc, False)) The script is running as a daemonised process using the code here . A number of class methods that are called as part of doChecks use the subprocess module to call system functions in order to get system statistics: ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE).communicate()[0] This runs fine for a period of time before the entire script crashing with the following error: File "/home/admin/sd-agent/checks.py", line 436, in getProcesses File "/usr/lib/python2.4/subprocess.py", line 533, in __init__ File "/usr/lib/python2.4/subprocess.py", line 835, in _get_handles OSError: [Errno 12] Cannot allocate memory The output of free -m on the server once the script has crashed is: $ free -m total used free shared buffers cached Mem: 894 345 549 0 0 0 -/+ buffers/cache: 345 549 Swap: 0 0 0 The server is running CentOS 5.3. I am unable to reproduce on my own CentOS boxes nor with any other user reporting the same problem. I have tried a number of things to debug this as suggested in the original question: Logging the output of free -m before and after the Popen call. There is no significant change in memory usage i.e. memory is not gradually being used up as the script runs. I added close_fds=True to the Popen call but this made no difference - the script still crashed with the same error. Suggested here and here . I checked the rlimits which showed (-1, -1) on both RLIMIT_DATA and RLIMIT_AS as suggested here . An article suggested the having no swap space might be the cause but swap is actually available on demand (according to the web host) and this was also suggested as a bogus cause here . The processes are being closed because that is the behaviour of using .communicate() as backed up by the Python source code and comments here . The entire checks can be found at on GitHub here with the getProcesses function defined from line 442. This is called by doChecks() starting at line 520. The script was run with strace with the following output before the crash: recv(4, "Total Accesses: 516662\nTotal kBy"..., 234, 0) = 234 gettimeofday({1250893252, 887805}, NULL) = 0 write(3, "2009-08-21 17:20:52,887 - checks"..., 91) = 91 gettimeofday({1250893252, 888362}, NULL) = 0 write(3, "2009-08-21 17:20:52,888 - checks"..., 74) = 74 gettimeofday({1250893252, 888897}, NULL) = 0 write(3, "2009-08-21 17:20:52,888 - checks"..., 67) = 67 gettimeofday({1250893252, 889184}, NULL) = 0 write(3, "2009-08-21 17:20:52,889 - checks"..., 81) = 81 close(4) = 0 gettimeofday({1250893252, 889591}, NULL) = 0 write(3, "2009-08-21 17:20:52,889 - checks"..., 63) = 63 pipe([4, 5]) = 0 pipe([6, 7]) = 0 fcntl64(7, F_GETFD) = 0 fcntl64(7, F_SETFD, FD_CLOEXEC) = 0 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7f12708) = -1 ENOMEM (Cannot allocate memory) write(2, "Traceback (most recent call last"..., 35) = 35 open("/usr/bin/sd-agent/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/bin/sd-agent/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python24.zip/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/plat-linux2/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python2.4/lib-tk/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/lib-dynload/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/site-packages/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) write(2, " File \"/usr/bin/sd-agent/agent."..., 52) = 52 open("/home/admin/sd-agent/daemon.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/bin/sd-agent/daemon.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python24.zip/daemon.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/daemon.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/plat-linux2/daemon.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python2.4/lib-tk/daemon.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/lib-dynload/daemon.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/site-packages/daemon.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) write(2, " File \"/home/admin/sd-agent/dae"..., 60) = 60 open("/usr/bin/sd-agent/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/bin/sd-agent/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python24.zip/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/plat-linux2/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python2.4/lib-tk/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/lib-dynload/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/site-packages/agent.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) write(2, " File \"/usr/bin/sd-agent/agent."..., 54) = 54 open("/usr/lib/python2.4/sched.py", O_RDONLY|O_LARGEFILE) = 8 write(2, " File \"/usr/lib/python2.4/sched"..., 55) = 55 fstat64(8, {st_mode=S_IFREG|0644, st_size=4054, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7d28000 read(8, "\"\"\"A generally useful event sche"..., 4096) = 4054 write(2, " ", 4) = 4 write(2, "void = action(*argument)\n", 25) = 25 close(8) = 0 munmap(0xb7d28000, 4096) = 0 open("/usr/bin/sd-agent/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/bin/sd-agent/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python24.zip/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/plat-linux2/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python2.4/lib-tk/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/lib-dynload/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/site-packages/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) write(2, " File \"/usr/bin/sd-agent/checks"..., 60) = 60 open("/usr/bin/sd-agent/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/bin/sd-agent/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python24.zip/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/plat-linux2/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOMEM (Cannot allocate memory) open("/usr/lib/python2.4/lib-tk/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/lib-dynload/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/usr/lib/python2.4/site-packages/checks.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) write(2, " File \"/usr/bin/sd-agent/checks"..., 64) = 64 open("/usr/lib/python2.4/subprocess.py", O_RDONLY|O_LARGEFILE) = 8 write(2, " File \"/usr/lib/python2.4/subpr"..., 65) = 65 fstat64(8, {st_mode=S_IFREG|0644, st_size=39931, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7d28000 read(8, "# subprocess - Subprocesses with"..., 4096) = 4096 read(8, "lso, the newlines attribute of t"..., 4096) = 4096 read(8, "code < 0:\n print >>sys.st"..., 4096) = 4096 read(8, "alse does not exist on 2.2.0\ntry"..., 4096) = 4096 read(8, " p2cread\n # c2pread <-"..., 4096) = 4096 write(2, " ", 4) = 4 write(2, "errread, errwrite)\n", 19) = 19 close(8) = 0 munmap(0xb7d28000, 4096) = 0 open("/usr/lib/python2.4/subprocess.py", O_RDONLY|O_LARGEFILE) = 8 write(2, " File \"/usr/lib/python2.4/subpr"..., 71) = 71 fstat64(8, {st_mode=S_IFREG|0644, st_size=39931, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7d28000 read(8, "# subprocess - Subprocesses with"..., 4096) = 4096 read(8, "lso, the newlines attribute of t"..., 4096) = 4096 read(8, "code < 0:\n print >>sys.st"..., 4096) = 4096 read(8, "alse does not exist on 2.2.0\ntry"..., 4096) = 4096 read(8, " p2cread\n # c2pread <-"..., 4096) = 4096 read(8, "table(self, handle):\n "..., 4096) = 4096 read(8, "rrno using _sys_errlist (or siml"..., 4096) = 4096 read(8, " p2cwrite = None, None\n "..., 4096) = 4096 write(2, " ", 4) = 4 write(2, "self.pid = os.fork()\n", 21) = 21 close(8) = 0 munmap(0xb7d28000, 4096) = 0 write(2, "OSError", 7) = 7 write(2, ": ", 2) = 2 write(2, "[Errno 12] Cannot allocate memor"..., 33) = 33 write(2, "\n", 1) = 1 unlink("/var/run/sd-agent.pid") = 0 close(3) = 0 munmap(0xb7e0d000, 4096) = 0 rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x589978}, {0xb89a60, [], SA_RESTORER, 0x589978}, 8) = 0 brk(0xa022000) = 0xa022000 exit_group(1) = ? | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Escaping double curly braces in Ansible How to escape double curly braces in Ansible 1.9.2? For instance, how can I escape double curly braces in the following shell command? - name: Test shell: "docker inspect --format '{{ .NetworkSettings.IPAddress }}' instance1" | O O O O O B-PRODUCT O O O O O O O B-PRODUCT B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How do I get a variable with the name of the user running ansible? I'm scripting a deployment process that takes the name of the user running the ansible script (e.g. tlau) and creates a deployment directory on the remote system based on that username and the current date/time (e.g. tlau-deploy-2014-10-15-16:52). You would think this is available in ansible facts (e.g. LOGNAME or SUDO_USER), but those are all set to either "root" or the deployment id being used to ssh into the remote system. None of those contain the local user, the one who is currently running the ansible process. How can I script getting the name of the user running the ansible process and use it in my playbook? | O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O |
How can I copy files between two managed nodes using Ansible? I need to copy a file between two remote nodes: node A is a managed node where the file exists node B is a managed node where the file should be copied Please note that my control node, from where I run all my Ansible tasks, is none of the above mentioned nodes. I have tried the following: Use scp command in shell module of Ansible - hosts: machine2 user: user2 tasks: - name: Copy file from machine1 to machine2 shell: scp user1@machine1:/path-of-file/file1 /home/user2/file1 This approach just goes on and on never ends. Use the fetch and copy modules - hosts: machine1 user: user1 tasks: - name: copy file from machine1 to local fetch: src: /path-of-file/file1 dest: /path-of-file/file1 - hosts: machine2 user: user2 tasks: - name: copy file from local to machine2 copy: src: /path-of-file/file1 dest: /path-of-file/file1 This approach throws me an error as follows: error while accessing the file /Users//.ansible/cp/ansible-ssh-machine2-22-, error was: [Errno 102] Operation not supported on socket: u'/Users//.ansible/cp/ansible-ssh-machine2-22-' How can I achieve this? | O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O B-PRODUCT O O O O O O O O O O O O O O |
Missing sudo password in Ansible Ansible asks for sudo password from following code, it tries to create a new postgres user. Error message: fatal: [xxx.xxx.xxx.xxx] => Missing sudo password main.yml - name: 'Provision a PostgreSQL server' hosts: "dbservers" sudo: yes sudo_user: postgres roles: - postgres create_db.yml - name: Make sure the PostgreSQL users are present postgresql_user: name=rails password=secret role_attr_flags=CREATEDB,NOSUPERUSER sudo_user: postgres sudo: yes The remote_user that used to login to this machine is a non-root user, it has no password, and can only login using key auth. For user postgres , this account doesn't have the password as well, because the database was just installed. Since I logged in as non -root user, of course it will ask for password when switch to postgress account in order to create database user. But it won't be need for password if switch to postgres from root account. So, I wonder if there is a way to switch to root, and then switch to user postgres . Note: the root account has no public key, no password, and cannot login from SSH. | O O O O B-PRODUCT B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
error retrieving current directory: getcwd: cannot access parent directories I have a simple script: #!/bin/bash for server in $(~/.ansible/ansible_hosts) do ssh $server "hostname; readlink /opt/mydir/mylink;" done It works fine - the program returns the correct hostname and link - except that I get the following error on some but not all of the servers: shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory All the directories exist. One of the most common suggestions has been to add a cd, a cd -, or a cd /. All that happens when that step is added is an additional: chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory I tried kickstarting the nfs daemon on the off chance that there was some confusion about my homedir and substituted /etc/init.d in case the problem was with /opt. No difference This would simply be an annoyance except that when I try to use an ansible playbook instead of a simple ssh command it fails for that server. Any insights would appreciated. | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O |
Check if directory mounted with bash I am using mount -o bind /some/directory/here /foo/bar I want to check /foo/bar though with a bash script, and see if its been mounted? If not, then call the above mount command, else do something else. How can I do this? CentOS is the operating system. | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O |
How to free up space on docker devmapper and CentOS7? I am learning docker and I am using v1.11.0 I am trying to install hadoop but devmapper is complaining about free disk space? devmapper: Thin Pool has 82984 free data blocks which is less than minimum required 163840 free data blocks. Create more free space in thin pool or use dm.min_free_space option to change behavior I have deleted all my images but the problem persists: [root@localhost hadoop_docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE debian latest 47af6ca8a14a 3 weeks ago 125 MB [root@localhost hadoop_docker]# and this is my disk configuration: [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 8G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 7.5G 0 part ├─centos-root 253:0 0 6.7G 0 lvm / └─centos-swap 253:1 0 820M 0 lvm [SWAP] sr0 11:0 1 1024M 0 rom loop0 7:0 0 100G 0 loop └─docker-253:0-844682-pool 253:2 0 100G 0 dm loop1 7:1 0 2G 0 loop └─docker-253:0-844682-pool 253:2 0 100G 0 dm How can I free up the disk space? | O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How can I perform a git pull without re-entering my SSH password? Is it possible to configure git/ssh so I don't have to enter my passphrase every time I want to perform a git pull ? Note that the repo is a private one on github. Or, alternatively, what would be the best practice to automate code deployment from a private Github repo? Additional details: EC2 instance running a public AMI based on Fedora. | O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O |
How to copy files with ansible relatively to the role? I have a copy task inside a role and I was expecting that the src location would be relative to the role itself, not the playbook that calls the roles. How do I make this work and use the files from myfrole/files from a task inside myrole/tasks , I don't want to include the role name as part of the path as it does not make much sense. If I do it will break if I duplicate the role. | O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to run Ansible without specifying the inventory but the host directly? I want to run Ansible in Python without specifying the inventory file through (ANSIBLE_HOST) but just by: ansible.run.Runner( module_name='ping', host='www.google.com' ) I can actually do this in fabric easily but just wonder how to do this in Python. On the other hand, documentation of the Ansible API for python is not really complete. | O O O B-PRODUCT O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O B-PRODUCT O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O |
ansible : how to pass multiple commands I tried this: - command: ./configure chdir=/src/package/ - command: /usr/bin/make chdir=/src/package/ - command: /usr/bin/make install chdir=/src/package/ which works, but I was hoping for something neater. So I tried this: from: [URL] which give me back "no such file or directory" - command: ./configure;/usr/bin/make;/usr/bin/make install chdir=/src/package/ I tried this too: [URL] but I couldn't find the right syntax to put: - command: "{{ item }}" chdir=/src/package/ with_items: ./configure /usr/bin/make /usr/bin/make install That does not work, saying there is a quote issue. | B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How do I get logs/details of ansible-playbook module executions? Say I execute the following. $ cat test.sh #!/bin/bash echo Hello World exit 0 $ cat Hello.yml --- - hosts: MyTestHost tasks: - name: Hello yourself script: test.sh $ ansible-playbook Hello.yml PLAY [MyTestHost] **************************************************************** GATHERING FACTS *************************************************************** ok: [MyTestHost] TASK: [Hello yourself] ******************************************************** ok: [MyTestHost] PLAY RECAP ******************************************************************** MyTestHost : ok=2 changed=0 unreachable=0 failed=0 $ I know for sure that it was successful. Where/how do I see the "Hello World" echo'ed/printed by my script on the remote host (MyTestHost)? Or the return/exit code of script? My research shows me it would be possible to write a plugin to intercept module execution callbacks or something on those lines and write a log file. I would prefer to not waste my time with that. E.g. something like the stdout in below (note that I'm running ansible and not ansible-playbook): $ ansible plabb54 -i /project/plab/svn/plab-maintenance/ansible/plab_hosts.txt -m script -a ./test.sh plabb54 | success >> { "rc": 0, "stderr": "", "stdout": "Hello World\n" } $ | O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O B-PRODUCT I-PRODUCT I-PRODUCT O O O B-PRODUCT O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How can I randomize the lines in a file using standard tools on Red Hat Linux? How can I randomize the lines in a file using standard tools on Red Hat Linux? I don't have the shuf command, so I am looking for something like a perl or awk one-liner that accomplishes the same task. | O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O B-PRODUCT I-PRODUCT I-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to get a list of programs running with nohup I am accessing a server running CentOS (linux distribution) with an SSH connection. Since I can't always stay logged in, I use "nohup [command] &" to run my programs. I couldn't find how to get a list of all the programs I started using nohup. "jobs" only works out before I log out. After that, if I log back again, the jobs command shows me nothing, but I can see in my log files that my programs are still running. Is there a way to get a list of all the programs that I started using "nohup" ? | O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Ansible: filter a list by its attributes I have variable named "network" registered in Ansible: { "addresses": { "private_ext": [ { "type": "fixed", "addr": "172.16.2.100" } ], "private_man": [ { "type": "fixed", "addr": "172.16.1.100" }, { "type": "floating", "addr": "10.90.80.10" } ] } } Is it possible to get the IP address ("addr") with type="floating" doing something like this? - debug: var={{ network.addresses.private_man | filter type="fixed" | get "addr" }} I know the syntax is wrong but you get the idea. | B-PRODUCT O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
Run an Ansible task only when the variable contains a specific string I have multiple tasks depend from the value of variable1. I want to check if the value is in {{ variable1 }} but I get an error: - name: do something when the value in variable1 command: <command> when: "'value' in {{ variable1 }}" I'm using ansible 2.0.2 | O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION |
How do I register a variable and persist it between plays targeted on different nodes? I have an Ansible playbook , where I would like a variable I register in a first play targeted on one node to be available in a second play, targeted on another node. Here is the playbook I am using: --- - hosts: localhost gather_facts: no tasks: - command: echo "hello world" register: foo - hosts: main gather_facts: no tasks: - debug: msg: {{ foo.stdout }} But, when I try to access the variable in the second play, targeted on main , I get this message: The task includes an option with an undefined variable. The error was: 'foo' is undefined How can I access foo , registered on localhost , from main ? | O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O |
How to check all versions of Python installed on OS X and CentOS I just started setting up a CentOS server today and noticed that the default version of Python on CentOS is set to 2.6.6. I want to use Python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my Mac and found that I had Python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to look up all the versions of Python installed on CentOS so I don't accidentally install it twice. | O O O O O O O O O O O O B-PRODUCT O O O O O O B-PRODUCT O O O O O O O O O O O B-PRODUCT O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O B-VERSION I-VERSION I-VERSION O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O B-PRODUCT O O O O O O O O O O O O O O O O O O O O O O O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O B-VERSION I-VERSION I-VERSION I-VERSION I-VERSION O O O O O O O O O O O O O O O O O O O O O O O O O O B-PRODUCT O O O O O O O O O O |
No dataset card yet
- Downloads last month
- 12