I want to pass environment variables to the remote system I am bootstrapping but I am unable to do so.
Usecase:
Recipes which I am using needs artifactory username and password to download the artifacts.
Example : curl -u ${ARTIFACTORY_USER}:${ARTIFACTORY_PASS} -X GET ${Artifact URL}
but I am not able to pass the values.
Knife bootstrap command which I am using is
knife bootstrap ${IPAddress} -o winrm -x ${username} -P ${password} -N ${Chef_Node} --policy-group ${Policy_Group_Name} --policy-name ${PolicyFile_Name}
I tried sending the variable in knife.rb and config.rb file in the below format but didn't work.
knife[:ARTIFACTORY_USER] = ENV['ARTIFACTORY_USER']
knife[:ARTIFACTORY_PASS] = ENV['ARTIFACTORY_PASS']
Related
So you can't directly update a single item, but must get the entire config group associated with.
What I have done is:
# read the tag of target config i want
curl -u $USERNAME:$PASSWORD -H "X-Requested-By: ambari" -X GET $BASE_URI?fields=Clusters/desired_configs > .temp_json
# download my configs
curl -u $USERNAME:$PASSWORD -H "X-Requested-By: ambari" -X GET "$BASE_URI/configurations?type=$CONFIG_TYPE&tag=$TARGET_TAG" > .configs_to_update
# update configs here > UPDATED_FILE_HERE
# ??? (upload the configs)
The next step is to upload the configs to the server then restart the services. I can't seem to figure out the API call to upload the configs. Does anyone know how I can upload the configs with the Ambari REST API?
I am not sure if this helps your situation, but check out this command I use to make an adjustment to a single config:
python /var/lib/ambari-server/resources/scripts/configs.py -u admin -p admin -n HDP3 -l c7404.ambari.apache.org -t 8080 -a set -c cluster-env -k ignore_groupsusers_create -v true
I have a ansible playbook which I run manually from the command line by ansible-playbook -u <username> -k playbooks/example.yml
The above works fine. It prompts me for a SSH password and runs the playbook.
The ansible version in my linux machine: 2.7.7
I need to run this in Bamboo as part of my build plan. In Bamboo, I cannot type in the password as it will not prompt me. So I want to pass the username and ssh password as part of the command as arguments.
I tried this
ansible-playbook playbooks/monitor-linux-node.yml -e "ansible_user=<username> ansible_ssh_pass=password"
This throws this error
ERROR: blockinfile is not a legal parameter in an Ansible task or handler
I also tried this
ansible-playbook -u <username> playbooks/monitor-linux-node.yml -e "ansible_ssh_pass=password"
This throws the Usage: ansible-playbook playbook.yml and lists the arguments we can use.
Any suggestions on how to pass the username and ssh password in the command line will be really helpful.
The ansible version in Bamboo machine: 1.9.4
Consider using sshpass
sshpass -p <ssh-password> ansible-playbook -u <username> --ask-pass playbooks/monitor-linux-node.yml
Will be closest to what you want. If possible consider using password file
sshpass -f <password-file> ansible-playbook -u <username> --ask-pass playbooks/monitor-linux-node.yml
Note --ask-pass key. sshpass will provide password non-interactively instead of user.
If you are fine with having password stored unencrypted in a file anyway, consider using group_vars/<group name>.yml for defining ansible_ssh_pass variable. You will still need sshpass, but ansible will use it behind the scene.
I am trying to run chef-client remotely using knife run, however I would like to supply set of attributes at run time.
knife winrm -m 10.10.10.10 -x myuser -P mypassword chef-client
Ideal command:
knife winrm -m 10.10.10.10 -x myuser -P mypassword chef-client -j c:\.chef\dna.json
Node attribute data lives on the Chef Server, so you set it there (knife node edit, etc) rather than when you run chef-client. In general you can't easily change per-node data after initial creation, at least not without a bunch of caveats.
I have question about passing a shell script to an instance with user data. So what I need to configure here is, since my server is going to run on the instance, before the instance got created, the shell script should configure the server.xml information, (like the instance ip address, database ip addresss...) before starting the instance/server.
But, since the instance/server hasn't be generated yet, is there any variable I can use to pass the localhost information in the shell script? is there any way for user to specify some custom variable while running the user data before the instance got created? (before using the aws user data, I used to run it manually, through the configure.sh file and the config.properties file after the instance got created)
#!/bin/bash
# source the properties:
. ./config.properties
echo "Installation"
echo "Updating server.xml"
cd "Server/server/configuration/"
sed -i -s "s/SERVER_IP/"$LOCALHOST_IP"/g" server.xml
sed -i -s "s/DB_IP/"$DATABASE_IP"/g" server.xml
cd "../tomcat/bin"
sh startup.sh
I using passive mode FTP command provide by NCFTP, Currently i want to pass a raw ftp command after file transferred. i found that got an option to do that:
ncftpput -u user -p password -X "rename 123.exe 1234.exe" host /path C:\123.exe
however, it is not working. It can put the file, but rename command not working.
Have anyone did that before?Pls help
-X use RAW FTP commands
Use the following syntax:
ncftpput -u user -p password -X "RNFR 123.exe" -X "RNTO 1234.exe" host /path/123.exe
It works with ncftls as well. It is more immediate if you what you have to do is just a rename without actually uploading anything on the FTP server.
(-W is like -X. The only difference is that it does the rename immediately after logging in)
Here is the syntax:
ncftpls -u name -p psw -W "RNFR FTPfolder/anotherFolder/OLDname.txt" -W "RNTO FTPfolder/anotherFolder/NEWname.txt" ftp://ftp.name.org