我编写了以下代码,但未成功在目标服务器中安装Java 1.8版本。执行剧本时出错
---
- hosts: server
name: Fetch Java version
shell: java -version 2>&1 | grep version | awk '{print $3}' | sed 's/"//g'
register: java_version
- name: install java 1.8.* version
yum: name={{item}} state=latest
with_items:
- java-1.8.0-openjdk.x86_64
when: java_version != 1.8.*
答案 0 :(得分:0)
使用以下代码:
Sub SPOTImport() 'SPOT import
Dim Fname As Variant
Dim SrcWbk As Workbook
Dim DestWbk As Workbook
Dim LastRow1 As Variant
Dim LastRow2 As Variant
Dim LastRow3 As Variant
Dim LastRowHere As Variant
Dim i As Integer
Dim wbExport As Workbook
Dim wsToExport As Worksheet
Dim xPath As String
xPath = Application.ActiveWorkbook.Path
Set DestWbk = ThisWorkbook
'delete all data but header to begin the preparation
LastRowHere = DestWbk.Sheets("Import").Cells(Rows.Count, 1).End(xlUp).Row
DestWbk.Sheets("Import").Range("A2:I" & LastRowHere).Delete
'choose files and define them as array
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Välj alla filer som lämnades in", MultiSelect:=True)
If IsArray(Fname) Then
'Define array start and finish
For i = LBound(Fname) To UBound(Fname)
'define workbook name based on each value in array
Set SrcWbk = Workbooks.Open(Fname(i))
'define lastrow for each sheeet that also ignores the "" in formulas
LastRow1 = SrcWbk.Sheets("Import_EXPENSE").Columns("A").Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows, LookIn:=xlValues).Row
LastRow2 = SrcWbk.Sheets("Import_TRAVEL").Columns("A").Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows, LookIn:=xlValues).Row
LastRow3 = SrcWbk.Sheets("Import_ALLOWENCE").Columns("A").Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows, LookIn:=xlValues).Row
'copy data from each sheet to destnation file
SrcWbk.Sheets("Import_EXPENSE").Range("A2:I" & LastRow1).Copy
With DestWbk.Worksheets("Import").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.PasteSpecial Paste:=xlPasteValues
End With
SrcWbk.Sheets("Import_TRAVEL").Range("A2:I" & LastRow2).Copy
With DestWbk.Worksheets("Import").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.PasteSpecial Paste:=xlPasteValues
End With
SrcWbk.Sheets("Import_ALLOWENCE").Range("A2:I21" & LastRow3).Copy
With DestWbk.Worksheets("Import").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.PasteSpecial Paste:=xlPasteValues
End With
Application.DisplayAlerts = False
SrcWbk.Close False
Application.DisplayAlerts = True
Next i
End If
'export sheet as csv
Set wsToExport = ThisWorkbook.Worksheets("Import") 'Sheet to export as CSV
Set wbExport = Application.Workbooks.Add
wsToExport.Copy Before:=wbExport.Worksheets(wbExport.Worksheets.Count)
Application.DisplayAlerts = False 'Possibly overwrite without asking
wbExport.SaveAs Filename:=xPath & "\" & "SPOT Import" & " " & Format(Date, "yyyymmdd"), FileFormat:=xlCSV
Application.DisplayAlerts = True
wbExport.Close SaveChanges:=False
'select sheet
ThisWorkbook.Sheets("Import").Select
'magic ready
MsgBox "SPOT Import csv fil är klar!"
End Sub
如果存在上述版本,则Ansible状态将引起注意
注意:-请在问题中使用正确的格式