Thursday, 28 May 2020

Writing my first PlayBook on shell and local_action Module

Below is the structure of Playbook of generating HTML report using the shell and local_action Module

YAML
-  hosts:  localhost
   tasks:
     -  name:  checking 
        shell:  |
            a=$(hostnamectl | grep Chassis)
            a=$a{a// /}
            b=$(hostnamectl | grep "Icon name")
            b=$b{b// /}           
            echo "<html>
                  <head>
                  <style>
                  table, th, td {
                  border: 1px solid black;
                  }
                  </style>
                  </head>
                  <body>
                  <h2>Ansible Generating report</h2>
                  <p>Author - Anirban.</p>
                  <table style="width:20%">
                  <tr>
                  <th>Name</th>
                  <th>Information</th>    
                  </tr>
                  <tr>
                  <td>Chassis</td>
                  <td>$a</td>    
                  </tr>
                  <tr>
                  <td>Icon name</td>
                  <td>$b</td>    
                  </tr>  
                  </table>
                  </body>
                  </html>"
        register:  output

     -  name:  message
        debug:
          msg: "{{output.stdout}}"

     -  name: Generating the report
        local_action:  "copy content='{{output.stdout}}' dest=/home/anirban/Desktop/report.html"


Ansible Syntax check
   ansible-playbook systemreport.yml --syntax-check

Ansible Playbook
    ansible-playbook systemreport.yml

The outPut of the Playbook

Add caption







Wednesday, 13 May 2020

Display All the Owner of Group in FIM|MIM from a lists having the Groups Display Name


<# Summary : to pull all the group owner details in MIM
-- Anirban
#>
If(@(Get-PSSnapin | Where-Object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {Add-PSSnapin FIMAutomation}
$group=Get-Content "C:\Path_of_the_Grouplists\Group.txt"
foreach($i in $group) {
$Dynamic = @()
$config=Export-FIMConfig -Uri http://localhost:5725 -onlyBaseResources -customConfig "/Group[DisplayName ='$i']"
$g=(($config.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayName"}).Value)
$e=(($config.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "Email"}).Value)
$o=(($config.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayedOwner"}).Value)
$own=(($config.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "Owner"}).Values)
$g
$e
$o
$own
$mem="$o".replace("urn:uuid:","")
$mem
# Query the email Address of the Displayed owner.
$config1 = Export-FIMConfig -Uri http://localhost:5725 -onlyBaseResources -customConfig "/Person[ObjectID='$mem']"
$em=(($config1.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "Email"}).Value)
$em
# Query the email address of the others owner.
foreach($j in $own)
{
$x = "$j".Replace("urn:uuid:","")
$config2 = Export-FIMConfig -Uri http://localhost:5725 -onlyBaseResources -customConfig "/Person[ObjectID='$x']"
$em1=(($config2.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "Email"}).Value)
$Dynamic+= $em1
}
"$g,$e,$em,$Dynamic" >>C:\Group_Report.txt
}



ServiceNow onboarding Sailpoint