Compare commits
9 Commits
2215ee589a
...
e92347d035
Author | SHA1 | Date | |
---|---|---|---|
e92347d035 | |||
da132c5fb1 | |||
ec6cc7013c | |||
31a819e481 | |||
026969a32d | |||
65f44a8454 | |||
960f853d1f | |||
5fbc85dade | |||
befb02bc95 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
external
|
external
|
||||||
modules/win_git*
|
|
||||||
playbooks/test.yaml
|
playbooks/test.yaml
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[defaults]
|
[defaults]
|
||||||
collections_path = collections
|
collections_path = collections
|
||||||
library = modules
|
library = library
|
||||||
roles_path = roles
|
roles_path = roles
|
||||||
stdout_callback = yaml
|
stdout_callback = yaml
|
||||||
|
344
library/win_git.ps1
Normal file
344
library/win_git.ps1
Normal file
@ -0,0 +1,344 @@
|
|||||||
|
#!powershell
|
||||||
|
|
||||||
|
#AnsibleRequires -CSharpUtil Ansible.Basic
|
||||||
|
#AnsibleRequires -PowerShell Ansible.ModuleUtils.CommandUtil
|
||||||
|
|
||||||
|
$module = [Ansible.Basic.AnsibleModule]::Create($args, @{
|
||||||
|
options = @{
|
||||||
|
dest = @{ type = 'path' }
|
||||||
|
repo = @{ required = $true; aliases = @( 'name' ) }
|
||||||
|
version = @{ default = 'HEAD' }
|
||||||
|
remote = @{ default = 'origin' }
|
||||||
|
executable = @{ default = $null; type = 'path' }
|
||||||
|
}
|
||||||
|
supports_check_mode = $false
|
||||||
|
})
|
||||||
|
|
||||||
|
$dest = $module.Params.dest
|
||||||
|
$repo = $module.Params.repo
|
||||||
|
$version = $module.Params.version
|
||||||
|
$remote = $module.Params.remote
|
||||||
|
$git = $module.Params.executable
|
||||||
|
if ( !$git ) {
|
||||||
|
$git = Get-ExecutablePath 'git'
|
||||||
|
}
|
||||||
|
|
||||||
|
# ================================= Utilities ==================================
|
||||||
|
|
||||||
|
function Test-SshAcceptNewHostKey {
|
||||||
|
try {
|
||||||
|
$ssh = Get-ExecutablePath 'ssh'
|
||||||
|
} catch {
|
||||||
|
throw 'Remote host is missing ssh command, so you cannot use acceptnewhostkey option.'
|
||||||
|
}
|
||||||
|
$result = Run-Command "$ssh -o StrictHostKeyChecking=accept-new -V"
|
||||||
|
if ( $result.rc -ne 0 ) {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-AbsolutePath {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $path
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
$result = Resolve-Path $path
|
||||||
|
} catch {
|
||||||
|
return $_[0].TargetObject
|
||||||
|
}
|
||||||
|
return $result
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-GitDir {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $path
|
||||||
|
)
|
||||||
|
$git_dir = Join-Path $path '.git'
|
||||||
|
# Check if this .git is a file.
|
||||||
|
if ( [System.IO.File]::Exists($git_dir) ) {
|
||||||
|
# Extract the gitdir: path from the .git file.
|
||||||
|
$groups = Get-Content "$git_dir" | `
|
||||||
|
Select-String '(gitdir:) (.*)' | `
|
||||||
|
ForEach { $_.Matches[0].Groups[1..2] }
|
||||||
|
$ref_prefix = $groups[0]
|
||||||
|
$gitdir = $groups[1]
|
||||||
|
if ( $ref_prefix -ne 'gitdir:' ) {
|
||||||
|
$module.FailJson('The .git file has invalid gitdir reference format.')
|
||||||
|
}
|
||||||
|
# Check if the repo path is absolute.
|
||||||
|
if ( [System.IO.Path]::IsPathRooted($gitdir) ) {
|
||||||
|
$git_dir = $gitdir
|
||||||
|
} else {
|
||||||
|
# Join with the input path to construct an absolute path.
|
||||||
|
$git_dir = Join-Path $path $gitdir
|
||||||
|
}
|
||||||
|
if ( ![System.IO.Directory]::Exists($git_dir) ) {
|
||||||
|
throw "$git_dir is not a directory."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $git_dir
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-GitSshExecutablePath {
|
||||||
|
if ( $env:GIT_SSH ) {
|
||||||
|
return $env:GIT_SSH
|
||||||
|
}
|
||||||
|
if ( $env:GIT_SSH_COMMAND ) {
|
||||||
|
return $env:GIT_SSH_COMMAND
|
||||||
|
}
|
||||||
|
return Get-ExecutablePath 'ssh'
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-GitRemoteBranch {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $repository,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $branch
|
||||||
|
)
|
||||||
|
$command = "`"$git`" ls-remote $repository -h refs/heads/$branch"
|
||||||
|
$result = Run-Command -command $command
|
||||||
|
if ( $result.stdout.Contains($version) ) {
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-GitRemoteTag {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $repository,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $tag
|
||||||
|
)
|
||||||
|
$command = "`"$git`" ls-remote $repository -t refs/tags/$tag"
|
||||||
|
$result = Run-Command -command $command
|
||||||
|
if ( $result.stdout.Contains($version) ) {
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-GitLocalChanges {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest
|
||||||
|
)
|
||||||
|
$command = "`"$git`" status --porcelain"
|
||||||
|
$result = Run-Command -command $command -working_directory $dest
|
||||||
|
$changes = $result.stdout.Split([System.Environment]::NewLine, `
|
||||||
|
[System.StringSplitOptions]::RemoveEmptyEntries) | `
|
||||||
|
Where-Object { -not $_.StartsWith('??') } | Measure-Object -Line
|
||||||
|
return $changes.Lines -gt 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-GitRemoteHead {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $repo,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $version,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $remote
|
||||||
|
)
|
||||||
|
$cloning = $false
|
||||||
|
$cwd = $null
|
||||||
|
$tag = $false
|
||||||
|
if ( $remote -eq $repo ) {
|
||||||
|
$cloning = $true
|
||||||
|
} else {
|
||||||
|
$cwd = $dest
|
||||||
|
}
|
||||||
|
if ( $version -eq 'HEAD' ) {
|
||||||
|
if ( $cloning ) {
|
||||||
|
# Cloning the repo, just get the remote's HEAD version.
|
||||||
|
$command = "`"$git`" ls-remote $remote -h HEAD"
|
||||||
|
} else {
|
||||||
|
$head_branch = Get-GitRemoteHeadBranch $module $dest $remote
|
||||||
|
$command = "`"$git`" ls-remote $remote -h refs/heads/$head_branch"
|
||||||
|
}
|
||||||
|
} elseif ( Test-GitRemoteBranch $dest $remote $version ) {
|
||||||
|
$command = "`"$git`" ls-remote $remote -h refs/head/$version"
|
||||||
|
} elseif ( Test-GitRemoteTag $dest $remote $version ) {
|
||||||
|
$tag = $true
|
||||||
|
$command = "`"$git`" ls-remote $remote -t refs/tags/$version*"
|
||||||
|
} else {
|
||||||
|
# Appears to be a sha1, return as-is since it apparently not possible
|
||||||
|
# to check for a specific sha1 on remote.
|
||||||
|
return $version
|
||||||
|
}
|
||||||
|
$result = Run-Command -command $command -working_directory $cwd
|
||||||
|
if ( $result.rc -ne 0 -or $result.stdout.Length -lt 1 ) {
|
||||||
|
throw "Could not determine remote ref for $vesion"
|
||||||
|
}
|
||||||
|
$ref = $result.stdout
|
||||||
|
if ( $tag ) {
|
||||||
|
# Find the dereferenced tag if this is an annotated tag.
|
||||||
|
ForEach ( $tag in $ref.Split([System.Environment]::NewLine) ) {
|
||||||
|
if ( $tag.EndsWith("$version ^{}") ) {
|
||||||
|
$ref = $tag
|
||||||
|
} elseif ( $tag.EndsWith($version) ) {
|
||||||
|
$ref = $tag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ref.Split()[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-GitDetachedHead {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-GitRemoteHeadBranch {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $version,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $remote
|
||||||
|
)
|
||||||
|
$git_dir = Join-Path $dest '.git'
|
||||||
|
# TODO: Check if the .git is a file. If it is a file, it means that we are
|
||||||
|
# in a submodule structure.
|
||||||
|
$head_file = Join-Path $git_dir 'HEAD'
|
||||||
|
if ( Test-GitDetachedHead $dest ) {
|
||||||
|
$head_file = Join-Path $git_dir 'refs' 'remotes' $remote 'HEAD'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-GitCurrentSha {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest
|
||||||
|
)
|
||||||
|
$command = "`"$git`" rev-parse HEAD"
|
||||||
|
$result = Run-Command -command $command -working_directory $dest
|
||||||
|
return $result.stdout.Trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-GitRemoteUrl {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $remote
|
||||||
|
)
|
||||||
|
$command = "`"$git`" ls-remote --get-url $remote"
|
||||||
|
$result = Run-Command -command $command -working_directory $dest
|
||||||
|
if ( $result.rc -ne 0 ) {
|
||||||
|
# There was an issue getting the remote URL, most likely command is not
|
||||||
|
# available in this version of Git.
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
return $result.stdout.Trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
function Set-GitRemoteUrl {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $remote,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $url
|
||||||
|
)
|
||||||
|
# Return if remote URL isn't changing.
|
||||||
|
$remote_url = Get-GitRemoteUrl $dest $remote
|
||||||
|
if ( $remote_url -eq $repo ) {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
$command = "`"$git`" remote set-url $remote $url"
|
||||||
|
$result = Run-Command -command $command -working_directory $dest
|
||||||
|
if ( $result.rc -ne 0 ) {
|
||||||
|
$module.FailJson("Failed to set a new url $url for $remote`: $result.stderr")
|
||||||
|
}
|
||||||
|
# Return false if remote_url is null to maintain previous behavior for Git
|
||||||
|
# versions prior to 1.7.5 that lack required functionality.
|
||||||
|
return $remote_url -ne $null
|
||||||
|
}
|
||||||
|
|
||||||
|
function Invoke-GitClone {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $repo,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $remote,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest
|
||||||
|
)
|
||||||
|
$dest_parent = Split-Path -Path $dest -Parent
|
||||||
|
if ( !(Test-Path $dest_parent) ) {
|
||||||
|
New-Item -Path $dest_parent -ItemType Directory
|
||||||
|
}
|
||||||
|
$command = "`"$git`" clone --recursive --origin $remote $repo $dest"
|
||||||
|
if ( $version -ne "HEAD" ) {
|
||||||
|
$command += " --branch $version"
|
||||||
|
}
|
||||||
|
$result = Run-Command -command $command -working_directory $cwd
|
||||||
|
if ( $result.rc -ne 0 ) {
|
||||||
|
$module.FailJson($result.stderr)
|
||||||
|
}
|
||||||
|
# Ensure the newly cloned repository has the correct owner
|
||||||
|
$userName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
||||||
|
$idRef = [System.Security.Principal.NTAccount]::new($userName)
|
||||||
|
Get-Item $dest | foreach { `
|
||||||
|
$_ ; $_ | Get-ChildItem -Force -Recurse `
|
||||||
|
} | foreach { `
|
||||||
|
$acl = $_ | Get-Acl; $acl.SetOwner($idRef); $_ | Set-Acl -AclObject $acl `
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Invoke-GitFetch {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $repo,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $version,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $remote
|
||||||
|
)
|
||||||
|
$command = "`"$git`" fetch --tags $remote"
|
||||||
|
$result = Run-Command -command $command -working_directory $dest
|
||||||
|
if ( $result.rc -ne 0 ) {
|
||||||
|
$module.FailJson("Failed to download remote objects and refs:" + `
|
||||||
|
"$result.stdout $result.stderr")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Invoke-GitCheckout {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory = $true)] [String] $dest,
|
||||||
|
[Parameter(Mandatory = $true)] [String] $version
|
||||||
|
)
|
||||||
|
$result = Run-Command -command "`"$git`" checkout $version" -working_directory $dest
|
||||||
|
if ( $result.rc -ne 0 ) {
|
||||||
|
$module.FailJson("Failed to checkout version '$version': " + `
|
||||||
|
"$result.stdout $result.stderr")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ================================ Start logic =================================
|
||||||
|
|
||||||
|
if ( !$dest ) {
|
||||||
|
$module.FailJson('The destination directory must be specified.')
|
||||||
|
}
|
||||||
|
$dest = Get-AbsolutePath $dest
|
||||||
|
$git_dir = Get-GitDir $dest
|
||||||
|
$gitconfig = Join-Path $git_dir 'config'
|
||||||
|
|
||||||
|
$module.Result.before = $null
|
||||||
|
|
||||||
|
$local_changes = $false
|
||||||
|
if ( ($dest -and ![System.IO.File]::Exists($gitconfig)) -or (!$dest -and !$clone) ) {
|
||||||
|
Invoke-GitClone $repo $remote $dest $version
|
||||||
|
$module.Result.changed = $true
|
||||||
|
} else {
|
||||||
|
$local_changes = Test-GitLocalChanges $dest
|
||||||
|
$module.Result.before = Get-GitCurrentSha $dest
|
||||||
|
if ( $local_changes ) {
|
||||||
|
$module.FailJson('Local modifications exist in repository.')
|
||||||
|
}
|
||||||
|
# Checkout branch, if $version is HEAD get HEAD branch
|
||||||
|
# Pull
|
||||||
|
}
|
||||||
|
|
||||||
|
$module.ExitJson()
|
64
library/win_git.py
Normal file
64
library/win_git.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# TODO: copyright
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
---
|
||||||
|
module: win_git
|
||||||
|
author:
|
||||||
|
- "Kenneth Benzie (Benie)"
|
||||||
|
short_description: Deploy software (or files) from git checkouts on Windows
|
||||||
|
description:
|
||||||
|
- Manage git checkouts of repositories to deploy files or software on Windows.
|
||||||
|
options:
|
||||||
|
data:
|
||||||
|
description:
|
||||||
|
- Alternate data to return instead of 'pong'.
|
||||||
|
- If this parameter is set to C(crash), the module will cause an
|
||||||
|
exception.
|
||||||
|
type: str
|
||||||
|
default: pong
|
||||||
|
seealso:
|
||||||
|
- module: ansible.builtin.git
|
||||||
|
'''
|
||||||
|
|
||||||
|
# DOCUMENTATION = r'''
|
||||||
|
# ---
|
||||||
|
# module: win_ping
|
||||||
|
# short_description: A windows version of the classic ping module
|
||||||
|
# description:
|
||||||
|
# - Checks management connectivity of a windows host.
|
||||||
|
# - This is NOT ICMP ping, this is just a trivial test module.
|
||||||
|
# - For non-Windows targets, use the M(ansible.builtin.ping) module instead.
|
||||||
|
# options:
|
||||||
|
# data:
|
||||||
|
# description:
|
||||||
|
# - Alternate data to return instead of 'pong'.
|
||||||
|
# - If this parameter is set to C(crash), the module will cause an exception.
|
||||||
|
# type: str
|
||||||
|
# default: pong
|
||||||
|
# seealso:
|
||||||
|
# - module: ansible.builtin.ping
|
||||||
|
# author:
|
||||||
|
# - Chris Church (@cchurch)
|
||||||
|
# '''
|
||||||
|
|
||||||
|
EXAMPLES = r'''
|
||||||
|
# Test connectivity to a windows host
|
||||||
|
# ansible winserver -m ansible.windows.win_ping
|
||||||
|
|
||||||
|
- name: Example from an Ansible Playbook
|
||||||
|
ansible.windows.win_ping:
|
||||||
|
|
||||||
|
- name: Induce an exception to see what happens
|
||||||
|
ansible.windows.win_ping:
|
||||||
|
data: crash
|
||||||
|
'''
|
||||||
|
|
||||||
|
RETURN = r'''
|
||||||
|
ping:
|
||||||
|
description: Value provided with the data parameter.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: pong
|
||||||
|
'''
|
@ -5,3 +5,4 @@
|
|||||||
roles:
|
roles:
|
||||||
- role: kitty
|
- role: kitty
|
||||||
- role: xremap
|
- role: xremap
|
||||||
|
when: ansible_os_family == "RedHat"
|
||||||
|
@ -1,16 +1,24 @@
|
|||||||
---
|
---
|
||||||
- set_fact:
|
- name: set keyring path
|
||||||
keyring: /etc/apt/trusted.gpg.d/1password-archive-keyring.gpg
|
set_fact:
|
||||||
|
keyring: /etc/apt/keyrings/1password.asc
|
||||||
|
old_keyring: /etc/apt/trusted.gpg.d/1password-archive-keyring.gpg
|
||||||
|
|
||||||
|
- name: remove old keyring
|
||||||
|
become: true
|
||||||
|
file:
|
||||||
|
path: '{{old_keyring}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: add apt signing key
|
- name: add apt signing key
|
||||||
when: '"WSL" not in ansible_kernel'
|
when: '"WSL" not in ansible_kernel'
|
||||||
become: true
|
become: true
|
||||||
apt_key:
|
get_url:
|
||||||
url: https://downloads.1password.com/linux/keys/1password.asc
|
url: https://downloads.1password.com/linux/keys/1password.asc
|
||||||
keyring: '{{keyring}}'
|
dest: '{{keyring}}'
|
||||||
state: present
|
|
||||||
|
|
||||||
- when: ansible_machine == 'x86_64'
|
- name: set compatible architecture
|
||||||
|
when: ansible_machine == 'x86_64'
|
||||||
set_fact:
|
set_fact:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
@ -21,11 +29,11 @@
|
|||||||
- name: add apt repository
|
- name: add apt repository
|
||||||
when: '"WSL" not in ansible_kernel'
|
when: '"WSL" not in ansible_kernel'
|
||||||
become: true
|
become: true
|
||||||
apt_repository:
|
copy:
|
||||||
repo: >-
|
content: >-
|
||||||
deb [arch={{arch}} signed-by={{keyring}}]
|
deb [arch={{arch}} signed-by={{keyring}}]
|
||||||
https://downloads.1password.com/linux/debian/{{arch}} stable main
|
https://downloads.1password.com/linux/debian/{{arch}} stable main
|
||||||
filename: 1password
|
dest: /etc/apt/sources.list.d/1password.list
|
||||||
|
|
||||||
- name: install gui package
|
- name: install gui package
|
||||||
when: '"WSL" not in ansible_kernel'
|
when: '"WSL" not in ansible_kernel'
|
||||||
|
@ -25,11 +25,44 @@
|
|||||||
'http://apt.llvm.org/{{ubuntu_codename}}/'
|
'http://apt.llvm.org/{{ubuntu_codename}}/'
|
||||||
llvm_apt_category:
|
llvm_apt_category:
|
||||||
'llvm-toolchain-{{ubuntu_codename}}-{{llvm_major_version}}'
|
'llvm-toolchain-{{ubuntu_codename}}-{{llvm_major_version}}'
|
||||||
|
keyring: '/etc/apt/keyrings/llvm.asc'
|
||||||
|
|
||||||
|
- name: remove old keyring
|
||||||
|
when: '"WSL" not in ansible_kernel'
|
||||||
|
become: true
|
||||||
|
apt_key:
|
||||||
|
url: https://apt.llvm.org/llvm-snapshot.gpg.key
|
||||||
|
id: 6084F3CF814B57C1CF12EFD515CF4D18AF4F7421
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: remove old upstream deb repository
|
||||||
|
become: true
|
||||||
|
apt_repository:
|
||||||
|
repo: 'deb {{llvm_apt_repo_url}} {{llvm_apt_category}} main'
|
||||||
|
state: absent
|
||||||
|
filename: llvm
|
||||||
|
update_cache: false
|
||||||
|
|
||||||
|
- name: remove old upstream deb-src repository
|
||||||
|
become: true
|
||||||
|
apt_repository:
|
||||||
|
repo: 'deb-src {{llvm_apt_repo_url}} {{llvm_apt_category}} main'
|
||||||
|
state: absent
|
||||||
|
filename: llvm
|
||||||
|
update_cache: false
|
||||||
|
|
||||||
|
- name: add apt repository key
|
||||||
|
become: true
|
||||||
|
get_url:
|
||||||
|
url: https://apt.llvm.org/llvm-snapshot.gpg.key
|
||||||
|
dest: '{{keyring}}'
|
||||||
|
|
||||||
- name: add upstream deb repository
|
- name: add upstream deb repository
|
||||||
become: true
|
become: true
|
||||||
apt_repository:
|
apt_repository:
|
||||||
repo: 'deb {{llvm_apt_repo_url}} {{llvm_apt_category}} main'
|
repo: >
|
||||||
|
deb [signed-by={{keyring}}]
|
||||||
|
{{llvm_apt_repo_url}} {{llvm_apt_category}} main
|
||||||
state: present
|
state: present
|
||||||
filename: llvm
|
filename: llvm
|
||||||
update_cache: false
|
update_cache: false
|
||||||
@ -37,18 +70,13 @@
|
|||||||
- name: add upstream deb-src repository
|
- name: add upstream deb-src repository
|
||||||
become: true
|
become: true
|
||||||
apt_repository:
|
apt_repository:
|
||||||
repo: 'deb-src {{llvm_apt_repo_url}} {{llvm_apt_category}} main'
|
repo: >
|
||||||
|
deb-src [signed-by={{keyring}}]
|
||||||
|
{{llvm_apt_repo_url}} {{llvm_apt_category}} main
|
||||||
state: present
|
state: present
|
||||||
filename: llvm
|
filename: llvm
|
||||||
update_cache: false
|
update_cache: false
|
||||||
|
|
||||||
- name: add apt repository key
|
|
||||||
become: true
|
|
||||||
apt_key:
|
|
||||||
url: https://apt.llvm.org/llvm-snapshot.gpg.key
|
|
||||||
id: 6084F3CF814B57C1CF12EFD515CF4D18AF4F7421
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: update apt cache
|
- name: update apt cache
|
||||||
become: true
|
become: true
|
||||||
apt:
|
apt:
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
---
|
---
|
||||||
|
# TODO: Prefer Flatpak over AppImage if available
|
||||||
|
|
||||||
- name: stat symlink
|
- name: stat symlink
|
||||||
stat:
|
stat:
|
||||||
path: '{{ansible_env.HOME}}/.local/bin/Obsidian'
|
path: '{{ansible_env.HOME}}/.local/bin/Obsidian'
|
||||||
@ -13,6 +15,7 @@
|
|||||||
appimage: 'Obsidian-{{latest.json.name}}.AppImage'
|
appimage: 'Obsidian-{{latest.json.name}}.AppImage'
|
||||||
- set_fact:
|
- set_fact:
|
||||||
filepath: '{{ansible_env.HOME}}/.local/bin/{{appimage}}'
|
filepath: '{{ansible_env.HOME}}/.local/bin/{{appimage}}'
|
||||||
|
iconpath: 'share/icons/hicolor/512x512/apps/obsidian.png'
|
||||||
asset_query: '[?contains(name, `{{appimage}}`)] | [0]'
|
asset_query: '[?contains(name, `{{appimage}}`)] | [0]'
|
||||||
- set_fact:
|
- set_fact:
|
||||||
needs_installed:
|
needs_installed:
|
||||||
@ -25,13 +28,37 @@
|
|||||||
dest: '{{filepath}}'
|
dest: '{{filepath}}'
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: create directories
|
||||||
|
file:
|
||||||
|
path: '{{item}}'
|
||||||
|
state: directory
|
||||||
|
with_items:
|
||||||
|
- '{{ansible_env.HOME}}/.local/bin'
|
||||||
|
- '{{ansible_env.HOME}}/.local/share/icons/hicolor/512x512/apps'
|
||||||
|
|
||||||
- name: create symlink
|
- name: create symlink
|
||||||
file:
|
file:
|
||||||
src: '{{filepath}}'
|
src: '{{filepath}}'
|
||||||
dest: '{{ansible_env.HOME}}/.local/bin/Obsidian'
|
dest: '{{ansible_env.HOME}}/.local/bin/Obsidian'
|
||||||
state: link
|
state: link
|
||||||
|
|
||||||
# TODO: icon for desktop file
|
- name: extract squashfs-root for app icon
|
||||||
|
when: needs_installed
|
||||||
|
command:
|
||||||
|
cmd: '{{ansible_env.HOME}}/.local/bin/Obsidian --appimage-extract'
|
||||||
|
chdir: '/tmp'
|
||||||
|
|
||||||
|
- name: copy icon file
|
||||||
|
when: needs_installed
|
||||||
|
copy:
|
||||||
|
src: '/tmp/squashfs-root/usr/{{iconpath}}'
|
||||||
|
dest: '{{ansible_env.HOME}}/.local/{{iconpath}}'
|
||||||
|
|
||||||
|
- name: remove squashfs-root directory
|
||||||
|
when: needs_installed
|
||||||
|
file:
|
||||||
|
path: '/tmp/squashfs-root'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: create desktop file
|
- name: create desktop file
|
||||||
template:
|
template:
|
@ -1,2 +1,5 @@
|
|||||||
---
|
---
|
||||||
- include_tasks: '{{ansible_os_family}}.yaml'
|
- include_tasks: '{{ansible_os_family}}.yaml'
|
||||||
|
when: ansible_os_family == "Darwin" or ansible_os_family == "Windows"
|
||||||
|
- include_tasks: 'Linux.yaml'
|
||||||
|
when: ansible_os_family != "Darwin" and ansible_os_family != "Windows"
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
appimage: 'WebCatalog-{{releases[0].version}}.AppImage'
|
appimage: 'WebCatalog-{{releases[0].version}}.AppImage'
|
||||||
- set_fact:
|
- set_fact:
|
||||||
filepath: '{{ansible_env.HOME}}/.local/bin/{{appimage}}'
|
filepath: '{{ansible_env.HOME}}/.local/bin/{{appimage}}'
|
||||||
|
iconpath: 'share/icons/hicolor/512x512/apps/webcatalog.png'
|
||||||
|
|
||||||
- set_fact:
|
- set_fact:
|
||||||
needs_installed:
|
needs_installed:
|
||||||
@ -28,13 +29,37 @@
|
|||||||
dest: '{{ansible_env.HOME}}/.local/bin/{{appimage}}'
|
dest: '{{ansible_env.HOME}}/.local/bin/{{appimage}}'
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: create directories
|
||||||
|
file:
|
||||||
|
path: '{{item}}'
|
||||||
|
state: directory
|
||||||
|
with_items:
|
||||||
|
- '{{ansible_env.HOME}}/.local/bin'
|
||||||
|
- '{{ansible_env.HOME}}/.local/share/icons/hicolor/512x512/apps'
|
||||||
|
|
||||||
- name: create symlink
|
- name: create symlink
|
||||||
file:
|
file:
|
||||||
src: '{{filepath}}'
|
src: '{{filepath}}'
|
||||||
dest: '{{ansible_env.HOME}}/.local/bin/WebCatalog'
|
dest: '{{ansible_env.HOME}}/.local/bin/WebCatalog'
|
||||||
state: link
|
state: link
|
||||||
|
|
||||||
# TODO: icon for desktop file
|
- name: extract squashfs-root for app icon
|
||||||
|
when: needs_installed
|
||||||
|
command:
|
||||||
|
cmd: '{{ansible_env.HOME}}/.local/bin/WebCatalog --appimage-extract'
|
||||||
|
chdir: '/tmp'
|
||||||
|
|
||||||
|
- name: copy icon file
|
||||||
|
when: needs_installed
|
||||||
|
copy:
|
||||||
|
src: '/tmp/squashfs-root/usr/{{iconpath}}'
|
||||||
|
dest: '{{ansible_env.HOME}}/.local/{{iconpath}}'
|
||||||
|
|
||||||
|
- name: remove squashfs-root directory
|
||||||
|
when: needs_installed
|
||||||
|
file:
|
||||||
|
path: '/tmp/squashfs-root'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: create desktop file
|
- name: create desktop file
|
||||||
template:
|
template:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user