четверг, 5 октября 2017 г.

NO_PUBKEY while adding key in Ubuntu


For example:

W: GPG error: http://ppa.launchpad.net trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 93C4A3FD7BB9C367

go to http://keyserver.ubuntu.com/

search your key 0x93C4A3FD7BB9C367

Search results for '0x93c4a3fd7bb9c367'

Type bits/keyID     Date       User ID

pub  4096R/7BB9C367 2014-06-10 Launchpad PPA for Ansible, Inc.
  Fingerprint=6125 E2A8 C77F 2818 FB7B  D15B 93C4 A3FD 7BB9 C367 
 
 
 go to http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x93C4A3FD7BB9C367

save to file public key and add it to system with command

sudo apt-key add <file-with-key>

пятница, 11 ноября 2016 г.

Enable (Disable) TeamCity agents in specified pool


Python script that make Enabled or Disabled all agents in specified TeamCity pool

#!/usr/bin/python
# coding: UTF-8
#
# script running from console with 2 arguments
# 1st is pool name and 2nd is disable/enable (which what you want to do with agents enable or disable)
#
# Example: python ed_agents.py "Test Pool" disable
#

import sys
import xml.etree.ElementTree as ET
import requests

#Username for TeamCity
username = 'guest'
#password for TeamCity
passwd = username
#url of TeamCity
url = 'http://teamcity.corp'
poolnId = ''

#Function to do agents Disabled or Enabled
def agentAction(action):

        r = requests.get(listPoolAgents, auth=(username, passwd))
        content = r.content
        tree = ET.fromstring(content)

        if action == "disable":
                for place in tree.findall('agent'):
                        #taking link to agent
                        agentHref = place.get('href')
                        #taking name of agent
                        agentName = place.get('name')
                        agentDisable = url + agentHref + '/enabled'
                        #put request to TeamCity API
                        r = requests.put(agentDisable, data='false', auth=(username, passwd))
                        print "Agent " + agentName + " is disabled"
        if action == "enable":
                for place in tree.findall('agent'):
                        agentHref = place.get('href')
                        agentName = place.get('name')
                        agentEnable = url + agentHref + '/enabled'
                        r = requests.put(agentEnable, data='true', auth=(username, passwd))
                        print "Agent " + agentName + " is enabled"

#get list of all agents using TeamCity API
r = requests.get('http://teamcity.corp/httpAuth/app/rest/agentPools', auth=(username, passwd))
content = r.content
tree = ET.fromstring(content)

#taking id of pool what you need
for place in tree.findall('agentPool'):
        poolName = place.get('name')
        poolId = place.get('id')

        if (poolName == sys.argv[1]):
                poolnId = poolId

#creating url for pool's agents
listPoolAgents = 'http://teamcity.corp/app/rest/agentPools/id:' + poolnId + '/agents'

agentAction(sys.argv[2])

понедельник, 24 октября 2016 г.

How to configure nginx with AD authorozation

To provide nginx authorization via Microsoft Active Directory you should use the next commands in Ubuntu 16.04:
  1. apt update
  2. sudo apt install dpkg-dev libldap2-dev
  3. sudo add-apt-repository ppa:nginx/stable
  4. Edit sudo vim /etc/apt/sources.list.d/nginx-stable-trusty.list add dpkg-src:
    1. deb http://ppa.launchpad.net/nginx/stable/ubuntu xenial main
    2. deb-src http://ppa.launchpad.net/nginx/stable/ubuntu xenial main
  5. sudo apt update
  6. sudo apt-get source nginx
  7. sudo apt-get build-dep nginx
  8. Edit nginx-1.10.1/debian/rules and under section ‘full_configure_flags := \’ add following line:
    1. —add-module=$(MODULESDIR)/nginx-auth-ldap
  9. Inside modules directory “sudo git clone https://github.com/kvspb/nginx-auth-ldap.git
  10. cd /opt/nginx/nginx-1.10.1
  11. sudo dpkg-buildpackage -uc -us (or -b flag)
  12. Install generated packages inside /opt/nginx
    1. sudo dpkg —install nginx-common_1.10.1-1+xenial1_all.deb
    2. sudo dpkg —install nginx-full_1.10.1-1+xenial1_amd64.deb
  13. Edit main config file /etc/nginx/nginx.conf
  14. Edit /etc/nginx/fastcgi_params and add following:
    1. “fastcgi_param REMOTE_USER $remote_user”;
  15. sudo nginx -V to check if nginx-auth-ldap is loaded

 
This configuration lines you should insert into your main configuration file /etc/nginx/nginx.conf before the

include /etc/nginx/conf.d/*.conf; 
include /etc/nginx/sites-enabled/*;

ldap_server LDAP1 { 
   url "ldap://<ip-address>:3268/DC=<domain-name>,DC=com?sAMAccountName?sub?";
   binddn "<Bind Account>"; 
   binddn_passwd "<Bind Password>";  
   connect_timeout 5s; bind_timeout 5s;  
   request_timeout 5s; satisfy any;  
}

And the lines that goes below you shoud insert in the configuration file of your site
/etc/nginx/conf.d/something.conf in the server part and before location part:

auth_ldap "Restricted Access"; 
auth_ldap_servers LDAP1;

четверг, 29 сентября 2016 г.

Ansible change line in file on remote hosts


  If you want to change some line in some file (for exampe it would be /etc/environment and line that beginning from JAVA_HOME  ) on group of hosts with ansible you should use the next playbook:

---
- hosts: PCPool
  sudo: yes
  tasks:

    - name: Change line
      lineinfile: dest=/etc/environment regexp='^JAVA_HOME' line=JAVA_HOME="/usr/lib/jvm/java-8-oracle"


where hosts - group of hosts from ansible file hosts
          ineinfile - module of ansible

and in console you should use the next command:

 ansible-playbook change_line.yml -k --user=USER --ask-sudo-pass


if you want to chek the results:

ansible PCPool -u agent -k -m shell -a 'less /etc/invironment'

среда, 7 сентября 2016 г.

VSphere Client Windows 10 installation issues

If you have troubles with installing VSphere Client on Windows 10 with error "....NET 3.5 Framework..." you should to run this command where "E" you image with Windows 10.

DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:E:\sources\sxs

пятница, 2 сентября 2016 г.

Charles proxy Windows 10 issue


If you want to debug your application with Charles proxy on Windows 10 but Charles wont show connections from your application you should use Windows Loopback Exemptions Manager ( https://loopback.codeplex.com/ ) and add your application as Checked.

среда, 22 июня 2016 г.

TeamCity Host key verification failed error

TeamCity Build step failed- the error was:

 [Step 5/7] Host key verification failed.
[Step 5/7] fatal: The remote end hung up unexpectedly
 
To fix this you should run the next command on build agent:
 
git ls-remote -h ssh://git@URL_OF_STASH/PATH_TO_FILE.git
 
and type yes to add your stash server to known hosts.