Skip to main content

Posts

Showing posts with the label ssh

Useful ansible stuff

inventory_hostname ‘ inventory_hostname ‘ contains the name of the current node being worked on…. (as in, what it is defined in your hosts file as) so if you want to skip a task for a single node – - name: Restart amavis service: name=amavis state=restarted when: inventory_hostname != "boris" (Don’t restart Amavis for boris,  do for all others). You could also use : ... when: inventory_hostname not in groups['group_name'] ... if your aim was to (perhaps skip) a task for some nodes in the specified group.   Need to check whether you need to reboot for a kernel update? If /vmlinuz doesn’t resolve to the same kernel as we’re running Reboot Wait 45 seconds before carrying on… - name: Check for reboot hint. shell: if [ $(readlink -f /vmlinuz) != /boot/vmlinuz-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi ignore_errors: true register: reboot_hint - name: Rebooting ... command: shutdown -r now "Ansible kernel update applied...

Chef: Roles and Environments

Bootstrap another node with your chef-server. If you get the following error: Failed to read the private key /etc/chef/validation.pem: # In the same error logs you will see a line: Delete your validation key in order to use your user credentials instead Please check that you don't have any validation.pem key in /etc/chef, if any, then delete it. You can verify by executing one of the following: knife client list knife node show chef-node2 Create a new cookbook postgresql: chef generate cookbook cookbooks/postgresql Edit cookbooks/postgresql/recipes/default.rb [code] package 'postgresql-server' do notifies :run, 'execute[postgresql-init]' end execute 'postgresql-init' do command 'postgresql-setup initdb' action :nothing end service 'postgresql' do action [:enable, :start] end <span data-mce-type="bookmark" id="mce_SELREST_start" data-mce-style="overflow:h...

Jenkins: publish over ssh does not put files to remote server

Problem : I have strange issue on the latest Jenkins 1.634. Publish over ssh writes to log that it puts correctly file but nothing appears on remote server. e.g. I have logs SSH: cd  [var/www/data-fb-localtest] SSH: OK SSH: put  [asm.js] SSH: OK SSH: put  [asm.js.gz] SSH: OK SSH: put  [hero.data] SSH: OK SSH: put  [hero_main.js] SSH: OK SSH: cd  [/home/dev] SSH: OK SSH: cd  [var/www/data-fb-localtest/] SSH: OK SSH: put  [achievements.exm] SSH: OK SSH: put  [ai.exm] SSH: OK SSH: put  [atlas0.atlas] SSH: OK SSH: put  [atlas0.rgbz] SSH: OK but nothing appears in var/www/data-fb-localtest Solution : I found the issue. I do not set root remote directory and in publish task use absolute path. But plugin does use not absolute path but path relative to my user’s home directory

Jenkins – Publish Over SSH Plugin: How to copy directory

Problem: I’m trying to use  Jenkins’ Publish Over SSH  plugin to copy all files AND sub-directories of some given directory, but so far, I’ve only able to copy files and NOT directory. I have a directory named  foo  in my workspace, and during the build, I want to copy everything in this directory to a remote server. I’ve tried this pattern  foo/** , but it doesn’t copy all sub-directories. Solution: For recursive copy of directory you should give foo/**/*

How to prevent a user from login in, but allow “su – user” in Linux?

You can use  AllowUsers  /  AllowGroups  if you have only a few users/groups that are allowed to login via ssh or  DenyUsers  /  DenyGroups  if you have only a few users/groups that are  not  allowed to login. Note that this only restricts login via ssh, other ways of login (console, ftp, …) are still possible. You need to add these options to your  /etc/ssh/sshd_config  file for most ssh installations. If you have set the login shell to  /bin/false  you can use  su -s /bin/bash user  (replace  /bin/bash with the shell of your choice)

How to prevent a user from login in, but allow “su - user” in Linux?

You can use  AllowUsers  /  AllowGroups  if you have only a few users/groups that are allowed to login via ssh or  DenyUsers  /  DenyGroups  if you have only a few users/groups that are  not  allowed to login. Note that this only restricts login via ssh, other ways of login (console, ftp, ...) are still possible. You need to add these options to your  /etc/ssh/sshd_config  file for most ssh installations. If you have set the login shell to  /bin/false  you can use  su -s /bin/bash user  (replace  /bin/bash with the shell of your choice)

Jenkins - Publish Over SSH Plugin: How to copy directory

Problem: I'm trying to use  Jenkins' Publish Over SSH  plugin to copy all files AND sub-directories of some given directory, but so far, I've only able to copy files and NOT directory. I have a directory named  foo  in my workspace, and during the build, I want to copy everything in this directory to a remote server. I've tried this pattern  foo/** , but it doesn't copy all sub-directories. Solution: For recursive copy of directory you should give foo/**/*

Jenkins: publish over ssh does not put files to remote server

Problem : I have strange issue on the latest Jenkins 1.634. Publish over ssh writes to log that it puts correctly file but nothing appears on remote server. e.g. I have logs SSH: cd  [var/www/data-fb-localtest] SSH: OK SSH: put  [asm.js] SSH: OK SSH: put  [asm.js.gz] SSH: OK SSH: put  [hero.data] SSH: OK SSH: put  [hero_main.js] SSH: OK SSH: cd  [/home/dev] SSH: OK SSH: cd  [var/www/data-fb-localtest/] SSH: OK SSH: put  [achievements.exm] SSH: OK SSH: put  [ai.exm] SSH: OK SSH: put  [atlas0.atlas] SSH: OK SSH: put  [atlas0.rgbz] SSH: OK but nothing appears in var/www/data-fb-localtest   Solution : I found the issue. I do not set root remote directory and in publish task use absolute path. But plugin does use not absolute path but path relative to my user's home directory