PS C:\Users\Administrator\Documents> Find-Module Posh-SSH Version Name Type Repository Description ------- ---- ---- ---------- ----------- 1.7.7 Posh-SSH Module PSGallery Provide SSH functionality for executi... PS C:\Users\Administrator\Documents> Install-Module Posh-SSH Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolic y value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is 'Y'): PS C:\Users\Administrator\Documents> New-SSHSession -ComputerName "172.18.3.20" -Credential (Get-Credential) Windows PowerShell Credential Request : cmdlet Get-Credential at command pipeline position 1 Warning: This credential is being requested by a script or application on the STATBSPAPP remote computer. Enter your cr edentials only if you trust the remote computer and the application or script requesting it. Supply values for the following parameters: Credential: Enter your user name: root Enter your password: ***************** Server SSH Fingerprint Do you want to trust the fingerprint d4:d0:f9:cd:ad:22:ee:da:25:b2:2b:50:45:81:de:5a [] Y [] N [?] Help (default is 'N'): Y SessionId Host Connected --------- ---- --------- 0 172.18.3.20 True PS C:\Users\Administrator\Documents> Invoke-SSHCommand -Index 0 -Command "uname" Host : 172.18.3.20 Output : {SunOS} ExitStatus : 0 PS C:\Users\Administrator\Documents> Invoke-SSHCommand -Index 0 -Command "su - oracle -c id -u -n" Host : 172.18.3.20 Output : {uid=901(oracle) gid=900(dba)} ExitStatus : 0
Tuesday, January 24, 2017
Execute SSH on PowerShell
Wednesday, January 18, 2017
Windows Remote Management and PowerShell Web Access
PS C:\Users\Administrator> dir WSMan:\localhost\Listener\*\Port WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Listener\Listener_1084132640 Type Name SourceOfValue Value ---- ---- ------------- ----- System.String Port 5985 PS C:\Users\Administrator> Set-Item WSMan:\localhost\Listener\*\Port 8888 Set the value of the item This command set the value of the Item. Do you want to continue? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): PS C:\Users\Administrator> dir WSMan:\localhost\Listener\*\Port WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Listener\Listener_1892757853 Type Name SourceOfValue Value ---- ---- ------------- ----- System.String Port 8888 PS C:\Users\Administrator> PS C:\Users\Administrator> Enable-PSRemoting WinRM Quick Configuration Running command "Set-WSManQuickConfig" to enable remote management of this computer by using the Windows Remote Management (WinRM) service. This includes: 1. Starting or restarting (if already started) the WinRM service 2. Setting the WinRM service startup type to Automatic 3. Creating a listener to accept requests on any IP address 4. Enabling Windows Firewall inbound rule exceptions for WS-Management traffic (for http only). Do you want to continue? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): WinRM is already set up to receive requests on this computer. WinRM has been updated for remote management. Configured LocalAccountTokenFilterPolicy to grant administrative rights remotely to local users. Confirm Are you sure you want to perform this action? Performing the operation "Set-PSSessionConfiguration" on target "Name: microsoft.powershell SDDL: O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows PowerShell commands on this computer.". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Confirm Are you sure you want to perform this action? Performing the operation "Set-PSSessionConfiguration" on target "Name: microsoft.powershell.workflow SDDL: O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows PowerShell commands on this computer.". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Confirm Are you sure you want to perform this action? Performing the operation "Set-PSSessionConfiguration" on target "Name: microsoft.powershell32 SDDL: O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows PowerShell commands on this computer.". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Confirm Are you sure you want to perform this action? Performing the operation "Set-PSSessionConfiguration" on target "Name: microsoft.windows.servermanagerworkflows SDDL: O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows PowerShell commands on this computer.". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): PS C:\Users\Administrator> dir WSMan:\localhost\Listener\*\Port WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Listener\Listener_1892757853 Type Name SourceOfValue Value ---- ---- ------------- ----- System.String Port 8888
Check WinRM running with new ports
PS C:\Users\Administrator> netstat -aon | findstr "8888" TCP 0.0.0.0:8888 0.0.0.0:0 LISTENING 4 TCP [::]:8888 [::]:0 LISTENING 4 PS C:\Users\Administrator>
Install Web Access
PS C:\Users\Administrator> Install-WindowsFeature –Name WindowsPowerShellWebAccess -ComputerName MSERVER1 -IncludeManage mentTools -Restart Success Restart Needed Exit Code Feature Result ------- -------------- --------- -------------- True No Success {ASP.NET 4.5, Application Development, ASP... WARNING: For more information about how to finish installing and configuring Windows PowerShell Web Access, see http://go.microsoft.com/fwlink/?LinkID=221050. PS C:\Users\Administrator>
Config gateway
PS C:\Users\Administrator> Install-PswaWebApplication -UseTestCertificate WARNING: Using a test certificate in a production environment is not recommended for security reasons. This certificate should be used only for internal testing of Windows PowerShell Web Access. The test certificate expires in 90 days. Creating application pool pswa_pool... Name State Applications ---- ----- ------------ pswa_pool Started Creating web application pswa... Path : /pswa ApplicationPool : pswa_pool EnabledProtocols : http PhysicalPath : C:\Windows\Web\PowerShellWebAccess\wwwroot Creating self-signed certificate... Creating HTTPS binding... PS C:\Users\Administrator>
Add authorization rule
PS C:\Users\Administrator> hostname mserver1 PS C:\Users\Administrator> Add-PswaAuthorizationRule –UserName MSERVER1\Administrator -ComputerName MSERVER1 -Configurat ionName microsoft.powershell Id RuleName User Destination ConfigurationName -- -------- ---- ----------- ----------------- 0 Rule 0 MSERVER1\Administrator MSERVER1 microsoft.powershell PS C:\Users\Administrator> Add-PswaAuthorizationRule –UserName MSERVER1\CloudAdmin -ComputerName MSERVER1 -Configuration Name microsoft.powershell Id RuleName User Destination ConfigurationName -- -------- ---- ----------- ----------------- 1 Rule 1 MSERVER1\CloudAdmin MSERVER1 microsoft.powershell PS C:\Users\Administrator> Get-PswaAuthorizationRule Id RuleName User Destination ConfigurationName -- -------- ---- ----------- ----------------- 0 Rule 0 mserver1\administrator MSERVER1 microsoft.powershell 1 Rule 1 mserver1\cloudadmin MSERVER1 microsoft.powershell PS C:\Users\Administrator>
OR allow all user and configuration with
PS C:\Users\Administrator> Add-PswaAuthorizationRule –UserName * -ComputerName * -ConfigurationName * -- OR -- PS C:\Users\Administrator> Add-PswaAuthorizationRule * * *
Bingo !!!.
Open url => https://xx.xx.xx.xx/pswa
Welcome to PS session like below
Additional step for remote to machine in difference domain or non-domain manner.
Add trusted host
PS C:\Users\Administrator> Get-Item WSMan:\localhost\Client\TrustedHosts WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client Type Name SourceOfValue Value ---- ---- ------------- ----- System.String TrustedHosts STATBSPDB,172.19.3.13 PS C:\Users\Administrator> Set-Item WSMan:\localhost\Client\TrustedHosts -Value STATBBI -Force -Concatenate PS C:\Users\Administrator> Set-Item WSMan:\localhost\Client\TrustedHosts -Value 172.19.2.31 -Force -Concatenate PS C:\Users\Administrator> Get-Item WSMan:\localhost\Client\TrustedHosts WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client Type Name SourceOfValue Value ---- ---- ------------- ----- System.String TrustedHosts STATBSPDB,172.19.3.13,STATBBI,172.19.2.31
Test from local machine (gateway) when run Get-Credential, a windows is pop-up then enter a credential like "STATBBI\Administrator" and password of remote server.
PS C:\Users\Administrator> $C = Get-Credential cmdlet Get-Credential at command pipeline position 1 Supply values for the following parameters: Credential PS C:\Users\Administrator> Enter-PSSession -ComputerName STATBBI -Credential $C [STATBBI]: PS C:\Users\Administrator\Documents> [STATBBI]: PS C:\Users\Administrator\Documents> [STATBBI]: PS C:\Users\Administrator\Documents> hostname STATBBI
After that try to access from web by enter an info like below.
Sunday, January 15, 2017
Windows PowerShell Cmdlets
Get-Service -RequiredServices xxx Get-Service | Where-Object {$_.displayname -like "*Web*"} Get-Service | Sort-Object status,displayname Get-Service | Where-Object {$_.status -eq "running"} Get-Service | Where-Object {$_.status -eq "running" -and $_.displayname -like "*Application*"}Get-WmiObject win32_service | Where-Object {$_.displayname -like "SQL Server (MSSQLSERVER)"} | format-list *Get-Process Stop-Process -processname notepad Start-Service btwdins Stop-Service btwdins Restart-Service btwdins,alerter Stop-Computer -Force Stop-Computer -ComputerName "Server01", "Server02", "localhost" Stop-Computer –computer DC1 –Credential nwtraders\administrator Restart-Computer -WhatIf Restart-Computer "server01","server02","server03" Get-EventLog system -newest 5 | Sort-Object eventid -descendingGet-EventLog -LogName system -entrytype Error, Warning -After (Get-Date).AddDays(-3)PS C:\temp\PowerShell2> echo > test.ps1 cmdlet Write-Output at command pipeline position 1 Supply values for the following parameters: InputObject[0]: Get-EventLog system -newest 5 | Sort-Object eventid -descending InputObject[1]: Get-Process InputObject[2]: Get-Service InputObject[3]:Get-EventLog -LogName system -entrytype warning -After (Get-Date).AddDays(-3) | Where-Object {$_.Source -ne "disk"}Get-EventLog -Index 18308517 -Logname System | Format-List
PS C:\temp\PowerShell2> type test.ps1
Get-EventLog system -newest 5 | Sort-Object eventid -descending Get-Process Get-Service PS C:\temp\PowerShell2> powershell -ExecutionPolicy ByPass -File test.ps1
File Operation PowerShell
PS C:\SysInternals\sendmail> net use \\STATBSPDB\C$ password /USER:STATBSPDB\administrator The command completed successfully. PS C:\SysInternals\sendmail> Copy-Item \\STATBSPDB\c$\SysInternals\sendmail\EventDetail.txt . PS C:\SysInternals\sendmail> dir Directory: C:\SysInternals\sendmail Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 9/29/2009 11:02 AM 13589 CHANGELOG.txt -a--- 1/28/2017 11:00 PM 5 close-wait.txt -a--- 1/12/2017 1:16 PM 782 dbmem.sql -a--- 1/28/2017 11:01 PM 798 dbmem.txt -a--- 1/28/2017 11:20 PM 121856 EventDetail.txt -a--- 12/7/2016 3:15 PM 45501 eventlast3hrs.txt -a--- 1/28/2017 11:00 PM 255618 eventlast3hrs.xml -a--- 9/29/2009 11:03 AM 4701 README-BR.txt -a--- 9/29/2009 11:03 AM 8193 README.txt -a--- 9/29/2009 10:49 AM 1531966 sendEmail.exe -a--- 9/29/2009 1:46 PM 82448 sendEmail.pl -a--- 1/12/2017 3:02 PM 895 sendmail - Copy.cmd -a--- 1/20/2017 4:29 PM 907 sendmail.cmd -a--- 1/12/2017 2:57 PM 0 sqlcmd.log -a--- 9/29/2009 11:03 AM 1256 TODO.txt -a--- 5/13/2016 11:57 AM 66888 typeperf.htm -a--- 1/28/2017 11:00 PM 3594 typeperf.out -a--- 5/13/2016 12:22 PM 1170 typeperf.txt PS C:\SysInternals\sendmail> Copy-Item \\STATBSPDB\c$\SysInternals\sendmail\EventDetail_App.txt . PS C:\SysInternals\sendmail> dir PS C:\SysInternals\sendmail> Invoke-WebRequest -Uri "http://www.7-zip.org/a/7z1604-x64.msi" -OutFile "C:\SysInternals\7z1604-x64.msi" PS C:\SysInternals\sendmail> Start-Process "C:\SysInternals\7z1604-x64.msi" /qn -Wait PS C:\SysInternals\sendmail> cd 'C:\Program Files\7-Zip' PS C:\Program Files\7-Zip> .\7z.exe a C:\SysInternals\sendmail\EventDetail.zip C:\SysInternals\sendmail\EventDetail* 7-Zip [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04 Scanning the drive: 2 files, 29325476 bytes (28 MiB) Creating archive: C:\SysInternals\sendmail\EventDetail.zip Items to compress: 2 Files read from disk: 2 Archive size: 482093 bytes (471 KiB) Everything is Ok PS C:\Program Files\7-Zip> cd C:\SysInternals\sendmail\ PS C:\SysInternals\sendmail> dir Directory: C:\SysInternals\sendmail Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 9/29/2009 11:02 AM 13589 CHANGELOG.txt -a--- 1/29/2017 12:00 AM 5 close-wait.txt -a--- 1/12/2017 1:16 PM 782 dbmem.sql -a--- 1/29/2017 12:01 AM 798 dbmem.txt -a--- 1/28/2017 11:20 PM 121856 EventDetail.txt -a--- 1/29/2017 12:29 AM 482093 EventDetail.zip -a--- 1/28/2017 11:33 PM 29203620 EventDetail_App.txt -a--- 12/7/2016 3:15 PM 45501 eventlast3hrs.txt -a--- 1/29/2017 12:00 AM 260753 eventlast3hrs.xml -a--- 9/29/2009 11:03 AM 4701 README-BR.txt -a--- 9/29/2009 11:03 AM 8193 README.txt -a--- 9/29/2009 10:49 AM 1531966 sendEmail.exe -a--- 9/29/2009 1:46 PM 82448 sendEmail.pl -a--- 1/12/2017 3:02 PM 895 sendmail - Copy.cmd -a--- 1/20/2017 4:29 PM 907 sendmail.cmd -a--- 1/12/2017 2:57 PM 0 sqlcmd.log -a--- 9/29/2009 11:03 AM 1256 TODO.txt -a--- 5/13/2016 11:57 AM 66888 typeperf.htm -a--- 1/29/2017 12:00 AM 3595 typeperf.out -a--- 5/13/2016 12:22 PM 1170 typeperf.txt PS C:\SysInternals\sendmail> .\sendEmail -o -a EventDetail.zip -f spadmin@nso.go.th -t nutthaphon@gmail.com -s mailgw.nso.go.th:25 -u "Event Viewer" -m "FYI" Jan 29 00:30:30 statbspapp sendEmail.exe[213848]: Email was sent successfully! PS C:\SysInternals\sendmail>
SQL Server PowerShell
First of all, enable scripting restriction then load sqlps module.
PS C:\Users\Administrator\Documents> Set-ExecutionPolicy RemoteSigned PS C:\Users\Administrator\Documents> Import-Module sqlps -DisableNameChecking PS SQLSERVER:\>
Try it
PS SQLSERVER:\> Invoke-Sqlcmd -Query "SELECT GETDATE() AS TimeOfQuery;" -ServerInstance "STATBSPDB" –Username "sa" –Password "p@ssw0rd "-- or --
PS SQLSERVER:\> Invoke-Sqlcmd -ServerInstance . -Database master -Query "select GetDate()" Column1 ------- 19-Jan-17 2:54:07 PM
cd SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases PS SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases> cd WSS_Content PS SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases\WSS_Content> Invoke-Sqlcmd -Query "SELECT DB_NAME() as [Database]" WARNING: Using provider context. Server = STATBSPDB, Database = WSS_Content. Database -------- WSS_Content PS SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases\WSS_Content>
PS SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases\WSS_Content> ls tables -Force Schema Name Created ------ ---- ------- dbo AllDocs 02-May-14 3:46 PM dbo AllDocVersions 02-May-14 3:46 PM dbo AllFileFragments 02-May-14 3:46 PM dbo AllLinks 02-May-14 3:46 PM dbo AllLists 02-May-14 3:46 PM dbo AllListsAux 02-May-14 3:46 PM dbo AllListsItemCount 02-May-14 3:46 PM dbo AllListsPlus 02-May-14 3:46 PM dbo AllListUniqueFields 02-May-14 3:46 PM dbo AllLookupRelationships 02-May-14 3:46 PM dbo AllSites 02-May-14 3:46 PM dbo AllUserData 02-May-14 3:46 PM dbo AllUserDataJunctions 02-May-14 3:46 PM dbo AllWebParts 02-May-14 3:46 PM dbo AllWebs 02-May-14 3:46 PM
PS SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases\master> Set-Location SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases\master PS SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases\master> sql "select * from spt_monitor" WARNING: Using provider context. Server = STATBSPDB, Database = master. lastrun : 10-Feb-12 9:02:09 PM cpu_busy : 20 io_busy : 9 idle : 2707 pack_received : 39 pack_sent : 39 connections : 19 pack_errors : 0 total_read : 0 total_write : 0 total_errors : 0 PS SQLSERVER:\SQL\STATBSPDB\DEFAULT\Databases\master>
SharePoint PowerShell
Manual registration on Windows PowerShell
PS C:\Users\Administrator> C:\"Program Files"\"Common Files"\"microsoft shared"\"Web Server Extensions"\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1
-- OR --
Add-PSSnapin Microsoft.SharePoint.Powershell
Networking PowerShell
Get-DnsClientCache Clear-DnsClientCache Get-DnsClientGlobalSetting Get-DnsClientServerAddress Resolve-DnsName xx.yy.zz -server 172.18.1.11 Get-NetIPAddress Get-NetIPInterface Get-NetRoute Get-NetTCPConnection Get-NetTCPSetting Get-NetAdapter Get-NetAdapterAdvancedProperty Get-NetAdapterStatistics
Tuesday, January 10, 2017
Redhat Ansible Tower Installation
Check correct date time
[root@rhelnode1 jboss]# date อ. 10 ม.ค. 2560 03:04:44 EST [root@rhelnode1 jboss]# timedatectl Local time: อ. 2017-01-10 03:06:49 EST Universal time: อ. 2017-01-10 08:06:49 UTC RTC time: อ. 2017-01-10 08:06:48 Time zone: America/New_York (EST, -0500) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: no Last DST change: DST ended at อา. 2016-11-06 01:59:59 EDT อา. 2016-11-06 01:00:00 EST Next DST change: DST begins (the clock jumps one hour forward) at อา. 2017-03-12 01:59:59 EST อา. 2017-03-12 03:00:00 EDT [root@rhelnode1 jboss]# timedatectl [root@rhelnode1 jboss]# timedatectl set-ntp yes [root@rhelnode1 jboss]# timedatectl list-timezones | grep Bangkok Asia/Bangkok [root@rhelnode1 jboss]# [root@rhelnode1 jboss]# [root@rhelnode1 jboss]# [root@rhelnode1 jboss]# timedatectl set-timezone Asia/Bangkok [root@rhelnode1 jboss]# date อ. 10 ม.ค. 2560 15:14:10 ICT [root@rhelnode1 jboss]# timedatectl Local time: อ. 2017-01-10 15:14:32 ICT Universal time: อ. 2017-01-10 08:14:32 UTC RTC time: อ. 2017-01-10 08:14:17 Time zone: Asia/Bangkok (ICT, +0700) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a
Configure Repository Access (link) or download from url
Ref.
https://access.redhat.com/solutions/3358
http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F
[jboss@rhelnode1 ~]$ ls -lt total 736 -rw-r--r--. 1 jboss jboss 737047 ม.ค. 10 02:24 ansible-tower-setup-latest.tar.gz -rw-r--r--. 1 jboss jboss 14612 ม.ค. 10 02:23 epel-release-latest-7.noarch.rpm [jboss@rhelnode1 ~]$ sudo yum install epel-release-latest-7.noarch.rpm [sudo] password for jboss: Loaded plugins: search-disabled-repos Examining epel-release-latest-7.noarch.rpm: epel-release-7-8.noarch Marking epel-release-latest-7.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-8 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================== Installing: epel-release noarch 7-8 /epel-release-latest-7.noarch 24 k Transaction Summary ====================================================================================================================================================== Install 1 Package Total size: 24 k Installed size: 24 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-8.noarch 1/1 Verifying : epel-release-7-8.noarch 1/1 Installed: epel-release.noarch 0:7-8 Complete!
Subscribe to the new Extras channel/repo (link)
[root@rhelnode1 rhn]# subscription-manager register --auto-attach
Registering to: subscription.rhsm.redhat.com:443/subscription Username: nutthaphon@gmail.com Password: The system has been registered with ID: 7a8d7e9a-022e-47c8-a5e2-12102c7c4609 Installed Product Current Status: Product Name: Red Hat Enterprise Linux Server Status: Subscribed
[root@rhelnode1 rhn]# subscription-manager repos --enable rhel-7-server-extras-rpms
Repository 'rhel-7-server-extras-rpms' is enabled for this system.
[root@rhelnode1 rhn]# yum install ansible Loaded plugins: search-disabled-repos rhel-7-server-extras-rpms | 3.4 kB 00:00:00 rhel-7-server-rpms | 3.5 kB 00:00:00 (1/6): rhel-7-server-extras-rpms/x86_64/group | 104 B 00:00:01 (2/6): rhel-7-server-extras-rpms/x86_64/updateinfo | 120 kB 00:00:01 (3/6): rhel-7-server-extras-rpms/x86_64/primary_db | 162 kB 00:00:00 (4/6): rhel-7-server-rpms/7Server/x86_64/group | 701 kB 00:00:01 (5/6): rhel-7-server-rpms/7Server/x86_64/updateinfo | 1.8 MB 00:00:03 (6/6): rhel-7-server-rpms/7Server/x86_64/primary_db | 32 MB 00:00:24 Resolving Dependencies --> Running transaction check ---> Package ansible.noarch 0:2.2.0.0-4.el7 will be installed --> Processing Dependency: sshpass for package: ansible-2.2.0.0-4.el7.noarch --> Processing Dependency: python-paramiko for package: ansible-2.2.0.0-4.el7.noarch --> Processing Dependency: python-keyczar for package: ansible-2.2.0.0-4.el7.noarch --> Processing Dependency: python-jinja2 for package: ansible-2.2.0.0-4.el7.noarch --> Processing Dependency: python-httplib2 for package: ansible-2.2.0.0-4.el7.noarch --> Running transaction check ---> Package python-httplib2.noarch 0:0.7.7-3.el7 will be installed ---> Package python-jinja2.noarch 0:2.7.2-2.el7 will be installed --> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-2.el7.noarch --> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-2.el7.noarch ---> Package python-keyczar.noarch 0:0.71c-2.el7 will be installed --> Processing Dependency: python-pyasn1 for package: python-keyczar-0.71c-2.el7.noarch --> Processing Dependency: python-crypto for package: python-keyczar-0.71c-2.el7.noarch ---> Package python2-paramiko.noarch 0:1.16.1-1.el7 will be installed --> Processing Dependency: python2-ecdsa for package: python2-paramiko-1.16.1-1.el7.noarch ---> Package sshpass.x86_64 0:1.05-5.el7 will be installed --> Running transaction check ---> Package python-babel.noarch 0:0.9.6-8.el7 will be installed ---> Package python-markupsafe.x86_64 0:0.11-10.el7 will be installed ---> Package python2-crypto.x86_64 0:2.6.1-10.el7 will be installed --> Processing Dependency: libtomcrypt.so.0()(64bit) for package: python2-crypto-2.6.1-10.el7.x86_64 ---> Package python2-ecdsa.noarch 0:0.13-4.el7 will be installed ---> Package python2-pyasn1.noarch 0:0.1.9-7.el7 will be installed --> Running transaction check ---> Package libtomcrypt.x86_64 0:1.17-23.el7 will be installed --> Processing Dependency: libtommath >= 0.42.0 for package: libtomcrypt-1.17-23.el7.x86_64 --> Processing Dependency: libtommath.so.0()(64bit) for package: libtomcrypt-1.17-23.el7.x86_64 --> Running transaction check ---> Package libtommath.x86_64 0:0.42.0-4.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================== Installing: ansible noarch 2.2.0.0-4.el7 epel 4.6 M Installing for dependencies: libtomcrypt x86_64 1.17-23.el7 epel 224 k libtommath x86_64 0.42.0-4.el7 epel 35 k python-babel noarch 0.9.6-8.el7 rhel-7-server-rpms 1.4 M python-httplib2 noarch 0.7.7-3.el7 epel 70 k python-jinja2 noarch 2.7.2-2.el7 rhel-7-server-extras-rpms 516 k python-keyczar noarch 0.71c-2.el7 epel 218 k python-markupsafe x86_64 0.11-10.el7 rhel-7-server-rpms 25 k python2-crypto x86_64 2.6.1-10.el7 epel 475 k python2-ecdsa noarch 0.13-4.el7 epel 83 k python2-paramiko noarch 1.16.1-1.el7 epel 257 k python2-pyasn1 noarch 0.1.9-7.el7 rhel-7-server-rpms 100 k sshpass x86_64 1.05-5.el7 epel 21 k Transaction Summary ====================================================================================================================================================== Install 1 Package (+12 Dependent packages) Total download size: 7.9 M Installed size: 35 M Is this ok [y/d/N]: y Downloading packages: (1/13): libtommath-0.42.0-4.el7.x86_64.rpm | 35 kB 00:00:01 (2/13): libtomcrypt-1.17-23.el7.x86_64.rpm | 224 kB 00:00:01 (3/13): python-keyczar-0.71c-2.el7.noarch.rpm | 218 kB 00:00:00 warning: /var/cache/yum/x86_64/7Server/rhel-7-server-rpms/packages/python-babel-0.9.6-8.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Public key for python-babel-0.9.6-8.el7.noarch.rpm is not installed (4/13): python-babel-0.9.6-8.el7.noarch.rpm | 1.4 MB 00:00:02 (5/13): python-markupsafe-0.11-10.el7.x86_64.rpm | 25 kB 00:00:00 (6/13): python-httplib2-0.7.7-3.el7.noarch.rpm | 70 kB 00:00:02 (7/13): python2-crypto-2.6.1-10.el7.x86_64.rpm | 475 kB 00:00:00 Public key for python-jinja2-2.7.2-2.el7.noarch.rpm is not installed (8/13): python-jinja2-2.7.2-2.el7.noarch.rpm | 516 kB 00:00:01 (9/13): sshpass-1.05-5.el7.x86_64.rpm | 21 kB 00:00:00 (10/13): python2-pyasn1-0.1.9-7.el7.noarch.rpm | 100 kB 00:00:00 (11/13): python2-ecdsa-0.13-4.el7.noarch.rpm | 83 kB 00:00:01 (12/13): python2-paramiko-1.16.1-1.el7.noarch.rpm | 257 kB 00:00:01 (13/13): ansible-2.2.0.0-4.el7.noarch.rpm | 4.6 MB 00:00:09 ------------------------------------------------------------------------------------------------------------------------------------------------------ Total 846 kB/s | 7.9 MB 00:00:09 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release Importing GPG key 0xFD431D51: Userid : "Red Hat, Inc. (release key 2) <security@redhat.com>" Fingerprint: 567e 347a d004 4ade 55ba 8a5f 199e 2f91 fd43 1d51 Package : redhat-release-server-7.3-7.el7.x86_64 (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release Is this ok [y/N]: y Importing GPG key 0x2FA658E0: Userid : "Red Hat, Inc. (auxiliary key) <security@redhat.com>" Fingerprint: 43a6 e49c 4a38 f4be 9abf 2a53 4568 9c88 2fa6 58e0 Package : redhat-release-server-7.3-7.el7.x86_64 (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : sshpass-1.05-5.el7.x86_64 1/13 Installing : python-babel-0.9.6-8.el7.noarch 2/13 Installing : python2-pyasn1-0.1.9-7.el7.noarch 3/13 Installing : libtommath-0.42.0-4.el7.x86_64 4/13 Installing : libtomcrypt-1.17-23.el7.x86_64 5/13 Installing : python2-crypto-2.6.1-10.el7.x86_64 6/13 Installing : python-keyczar-0.71c-2.el7.noarch 7/13 Installing : python2-ecdsa-0.13-4.el7.noarch 8/13 Installing : python2-paramiko-1.16.1-1.el7.noarch 9/13 Installing : python-httplib2-0.7.7-3.el7.noarch 10/13 Installing : python-markupsafe-0.11-10.el7.x86_64 11/13 Installing : python-jinja2-2.7.2-2.el7.noarch 12/13 Installing : ansible-2.2.0.0-4.el7.noarch 13/13 Verifying : python-keyczar-0.71c-2.el7.noarch 1/13 Verifying : python-markupsafe-0.11-10.el7.x86_64 2/13 Verifying : python-jinja2-2.7.2-2.el7.noarch 3/13 Verifying : python-httplib2-0.7.7-3.el7.noarch 4/13 Verifying : python2-ecdsa-0.13-4.el7.noarch 5/13 Verifying : libtomcrypt-1.17-23.el7.x86_64 6/13 Verifying : ansible-2.2.0.0-4.el7.noarch 7/13 Verifying : libtommath-0.42.0-4.el7.x86_64 8/13 Verifying : python2-pyasn1-0.1.9-7.el7.noarch 9/13 Verifying : python-babel-0.9.6-8.el7.noarch 10/13 Verifying : python2-crypto-2.6.1-10.el7.x86_64 11/13 Verifying : python2-paramiko-1.16.1-1.el7.noarch 12/13 Verifying : sshpass-1.05-5.el7.x86_64 13/13 Installed: ansible.noarch 0:2.2.0.0-4.el7 Dependency Installed: libtomcrypt.x86_64 0:1.17-23.el7 libtommath.x86_64 0:0.42.0-4.el7 python-babel.noarch 0:0.9.6-8.el7 python-httplib2.noarch 0:0.7.7-3.el7 python-jinja2.noarch 0:2.7.2-2.el7 python-keyczar.noarch 0:0.71c-2.el7 python-markupsafe.x86_64 0:0.11-10.el7 python2-crypto.x86_64 0:2.6.1-10.el7 python2-ecdsa.noarch 0:0.13-4.el7 python2-paramiko.noarch 0:1.16.1-1.el7 python2-pyasn1.noarch 0:0.1.9-7.el7 sshpass.x86_64 0:1.05-5.el7 Complete!
/var sizing by requirements must more than 10Gb
If you download RHEL qcow2 image from Redhat Portal, a /var filesystem is in / root filesystem that space less than Ansible Tower recommentation. So you should create new disk and mount as /var instead of existing /var in / root filesystem.
$ sudo mkdir /tmp/var $ sudo mount /dev/vdb /tmp/var/ $ sudo rsync -avz /var/ /tmp/var/ $ sudo blkid
Add new line
$ sudo vi /etc/fstab
UUID=ac1cda02-5a44-4b04-b6ad-a28bf69639e6 /var xfs defaults 0 2
Reboot $ sudo restorecon -R /var
Starting, Stopping, and Restarting Tower
/usr/bin/ansible-tower-service [ start | stop | restart | status ]
[jboss@rhelnode1 ~]$ ansible-tower-service status Showing Tower Status Redirecting to /bin/systemctl status postgresql-9.4.service ● postgresql-9.4.service - PostgreSQL 9.4 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled) Active: active (running) since อ. 2017-01-10 21:30:22 ICT; 20min ago Process: 890 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS) Process: 845 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS) Main PID: 1990 (postgres) CGroup: /system.slice/postgresql-9.4.service ├─1990 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data ├─2167 postgres: logger process ├─2202 postgres: checkpointer process ├─2203 postgres: writer process ├─2204 postgres: wal writer process ├─2205 postgres: autovacuum launcher process ├─2206 postgres: stats collector process ├─2249 postgres: awx awx 127.0.0.1(60506) idle ├─2250 postgres: awx awx 127.0.0.1(60508) idle ├─2251 postgres: awx awx 127.0.0.1(60510) idle └─2253 postgres: awx awx 127.0.0.1(60530) idle Redirecting to /bin/systemctl status redis.service ● redis.service - Redis persistent key-value database Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/redis.service.d └─limit.conf Active: active (running) since อ. 2017-01-10 21:30:06 ICT; 20min ago Main PID: 841 (redis-server) CGroup: /system.slice/redis.service └─841 /usr/bin/redis-server 127.0.0.1:6379 Redirecting to /bin/systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since อ. 2017-01-10 21:30:18 ICT; 20min ago Docs: man:httpd(8) man:apachectl(8) Main PID: 853 (httpd) Status: "Total requests: 59; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─ 853 /usr/sbin/httpd -DFOREGROUND ├─2070 (wsgi:awx) -DFOREGROUND ├─2071 (wsgi:awx) -DFOREGROUND ├─2072 (wsgi:awx_plain -DFOREGROUND ├─2073 (wsgi:awx_plain -DFOREGROUND ├─2074 /usr/sbin/httpd -DFOREGROUND ├─2075 /usr/sbin/httpd -DFOREGROUND ├─2076 /usr/sbin/httpd -DFOREGROUND ├─2077 /usr/sbin/httpd -DFOREGROUND ├─2078 /usr/sbin/httpd -DFOREGROUND ├─2302 /usr/sbin/httpd -DFOREGROUND ├─2307 /usr/sbin/httpd -DFOREGROUND ├─2308 /usr/sbin/httpd -DFOREGROUND ├─2310 /usr/sbin/httpd -DFOREGROUND └─2329 /usr/sbin/httpd -DFOREGROUND Redirecting to /bin/systemctl status supervisord.service ● supervisord.service - Process Monitoring and Control Daemon Loaded: loaded (/usr/lib/systemd/system/supervisord.service; enabled; vendor preset: disabled) Active: active (running) since อ. 2017-01-10 21:30:03 ICT; 20min ago Process: 510 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS) Main PID: 642 (supervisord) CGroup: /system.slice/supervisord.service ├─ 642 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf ├─ 659 python /usr/bin/tower-manage run_socketio_service ├─ 660 python /usr/bin/tower-manage run_fact_cache_receiver ├─ 661 python /usr/bin/tower-manage run_task_system ├─ 662 python /usr/bin/tower-manage celery worker -B -l debug --autoscale=50,4 -Ofair -s /var/lib/awx/beat.db ├─ 663 python /usr/bin/tower-manage run_callback_receiver ├─2256 python /usr/bin/tower-manage run_callback_receiver ├─2257 python /usr/bin/tower-manage run_callback_receiver ├─2258 python /usr/bin/tower-manage run_callback_receiver ├─2259 python /usr/bin/tower-manage run_callback_receiver ├─2260 python /usr/bin/tower-manage run_callback_receiver ├─2279 python /usr/bin/tower-manage celery worker -B -l debug --autoscale=50,4 -Ofair -s /var/lib/awx/beat.db ├─2280 python /usr/bin/tower-manage celery worker -B -l debug --autoscale=50,4 -Ofair -s /var/lib/awx/beat.db ├─2281 python /usr/bin/tower-manage celery worker -B -l debug --autoscale=50,4 -Ofair -s /var/lib/awx/beat.db ├─2282 python /usr/bin/tower-manage celery worker -B -l debug --autoscale=50,4 -Ofair -s /var/lib/awx/beat.db └─2283 python /usr/bin/tower-manage celery worker -B -l debug --autoscale=50,4 -Ofair -s /var/lib/awx/beat.db
Change admin user password
[jboss@rhelnode1 ~]$ sudo tower-manage changepassword admin [sudo] password for jboss: Changing password for user 'admin' Password: Password (again): Password changed successfully for user 'admin'
Changing the password on the RHEL 7 kvm qcow2
[nutt@nutt-pc ~]$ sudo apt-get install libguestfs-tools [sudo] password for nutt: Sorry, try again. [sudo] password for nutt: Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: archdetect-deb authbind curtin-common dbconfig-common dbconfig-pgsql distro-info docutils-common fonts-font-awesome formencode-i18n freeipmi-common freeipmi-tools ieee-data isc-dhcp-server libconfig-general-perl libdebian-installer4 libecap3 libfreeipmi16 libibverbs1 libipmiconsole2 libipmidetect0 libirs-export141 libisccfg-export140 libjs-angularjs libjs-modernizr libjs-sphinxdoc libjs-yui3-common libjs-yui3-full libjs-yui3-min librdmacm1 linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-headers-4.4.0-28 linux-headers-4.4.0-28-generic linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic linux-headers-4.4.0-34 linux-headers-4.4.0-34-generic linux-headers-4.4.0-38 linux-headers-4.4.0-38-generic linux-headers-4.4.0-42 linux-headers-4.4.0-42-generic linux-headers-4.4.0-43 linux-headers-4.4.0-43-generic linux-headers-4.4.0-45 linux-headers-4.4.0-45-generic linux-headers-4.4.0-47 linux-headers-4.4.0-47-generic linux-image-4.4.0-43-generic linux-image-4.4.0-45-generic linux-image-4.4.0-47-generic linux-image-extra-4.4.0-43-generic linux-image-extra-4.4.0-45-generic linux-image-extra-4.4.0-47-generic postgresql pxelinux python-babel-localedata python-django-common python3-alabaster python3-attr python3-babel python3-bson python3-bson-ext python3-convoy python3-crochet python3-curtin python3-distro-info python3-django python3-django-piston3 python3-djorm-ext-pgarray python3-dnspython python3-docutils python3-ecdsa python3-formencode python3-iso8601 python3-jsonschema python3-mimeparse python3-netaddr python3-netifaces python3-oauth python3-pam python3-paramiko python3-pbr python3-petname python3-prettytable python3-psycopg2 python3-pyasn1-modules python3-pygments python3-pyvmomi python3-roman python3-seamicroclient python3-serial python3-service-identity python3-simplejson python3-simplestreams python3-sphinx python3-sphinx-rtd-theme python3-sqlparse python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface sphinx-common sphinx-rtd-theme-common squid squid-common squid-langpack tgt ubuntu-cloudimage-keyring Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: btrfs-tools cryptsetup cryptsetup-bin dmeventd dmsetup extlinux hfsplus libconfig9 libdevmapper-event1.02.1 libguestfs-hfsplus libguestfs-perl libguestfs-reiserfs libguestfs-xfs libguestfs0 libhfsp0 libhivex0 liblvm2app2.2 liblvm2cmd2.02 libreadline5 libstring-shellquote-perl libsys-virt-perl libwin-hivex-perl libxml-xpath-perl lsscsi lvm2 lzop mdadm reiserfsprogs scrub supermin xfsprogs zerofree Suggested packages: keyutils libguestfs-gfs2 libguestfs-jfs libguestfs-nilfs libguestfs-rescue libguestfs-rsync libguestfs-zfs thin-provisioning-tools default-mta | mail-transport-agent xfsdump quota The following NEW packages will be installed: btrfs-tools cryptsetup cryptsetup-bin dmeventd dmsetup extlinux hfsplus libconfig9 libdevmapper-event1.02.1 libguestfs-hfsplus libguestfs-perl libguestfs-reiserfs libguestfs-tools libguestfs-xfs libguestfs0 libhfsp0 libhivex0 liblvm2app2.2 liblvm2cmd2.02 libreadline5 libstring-shellquote-perl libsys-virt-perl libwin-hivex-perl libxml-xpath-perl lsscsi lvm2 lzop mdadm reiserfsprogs scrub supermin xfsprogs zerofree 0 upgraded, 33 newly installed, 0 to remove and 14 not upgraded. Need to get 10.5 MB of archives. After this operation, 48.2 MB of additional disk space will be used. Do you want to continue? [Y/n] Y
Generate encrypted password with openssl then copy output string and paste in shadow file in next steps
[nutt@nutt-pc KVM]$ openssl passwd -1 changeme $1$twJh0TGA$ebVI529VkTMaICf0Oyvac/
[nutt@nutt-pc KVM]$ sudo guestfish --rw -a ./RHEL7_Node2.qcow2 Welcome to guestfish, the guest filesystem shell for editing virtual machine filesystems and disk images. Type: 'help' for help on commands 'man' to read the manual 'quit' to quit the shell ><fs> run 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 ><fs> list-filesystems /dev/sda1: xfs ><fs> mount /dev/sda1 / ><fs> df Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 4128448 424048 3494688 11% / tmpfs 97548 292 97256 1% /run /dev 240748 0 240748 0% /dev /dev/sda1 8181760 970692 7211068 12% /sysroot ><fs> vi /etc/shadow ><fs> quit
Reference: https://access.redhat.com/discussions/664843
Subscribe to:
Posts (Atom)