From 5cb0525430f0c53844656f6647c6dd47a5d2ec94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jir=CC=8Ci=CC=81=20Kubi=CC=81c=CC=8Cek?= Date: Thu, 30 May 2013 01:05:14 +0200 Subject: [PATCH] Add some FreeBSD facts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit added: * ansible_distribution * ansible_distribution_release * ansible_distribution_version * ansible_os_family * ansible_pkg_mgr * ansible_ssh_host_key_ecdsa_public Also adds ECDSA public key for all plaforms. --- CHANGELOG.md | 2 +- library/system/setup | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fe362f91c..162fda7fcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -122,7 +122,7 @@ the variable is still registered for the host, with the attribute skipped: True. * pip works better when sudoing from unpriveledged users * fix for user creation with groups specification reporting 'changed' incorrectly in some cases * fix for some unicode encoding errors in outputing some data in verbose mode -* improved NetBSD and Solaris facts +* improved FreeBSD, NetBSD and Solaris facts * debug module always outputs data without having to specify -v 1.1 "Mean Street" -- 4/2/2013 diff --git a/library/system/setup b/library/system/setup index 15a593b266..5e4c76c3f3 100644 --- a/library/system/setup +++ b/library/system/setup @@ -121,6 +121,7 @@ class Facts(object): { 'path' : '/opt/local/bin/pkgin', 'name' : 'pkgin' }, { 'path' : '/opt/local/bin/port', 'name' : 'macports' }, { 'path' : '/sbin/apk', 'name' : 'apk' }, + { 'path' : '/usr/sbin/pkg', 'name' : 'pkgng' }, ] def __init__(self): @@ -175,7 +176,8 @@ class Facts(object): SLED = 'Suse', OpenSuSE = 'Suse', SuSE = 'Suse', Gentoo = 'Gentoo', Archlinux = 'Archlinux', Mandriva = 'Mandrake', Mandrake = 'Mandrake', Solaris = 'Solaris', Nexenta = 'Solaris', OmniOS = 'Solaris', OpenIndiana = 'Solaris', - SmartOS = 'Solaris', AIX = 'AIX', Alpine = 'Alpine', MacOSX = 'Darwin' + SmartOS = 'Solaris', AIX = 'AIX', Alpine = 'Alpine', MacOSX = 'Darwin', + FreeBSD = 'FreeBSD' ) if self.facts['system'] == 'AIX': @@ -189,6 +191,10 @@ class Facts(object): rc, out, err = module.run_command("/usr/bin/sw_vers -productVersion") data = out.split()[-1] self.facts['distribution_version'] = data + elif self.facts['system'] == 'FreeBSD': + self.facts['distribution'] = 'FreeBSD' + self.facts['distribution_release'] = platform.release() + self.facts['distribution_version'] = platform.version() else: dist = platform.dist() self.facts['distribution'] = dist[0].capitalize() or 'NA' @@ -245,12 +251,15 @@ class Facts(object): def get_public_ssh_host_keys(self): dsa_filename = '/etc/ssh/ssh_host_dsa_key.pub' rsa_filename = '/etc/ssh/ssh_host_rsa_key.pub' + ecdsa_filename = '/etc/ssh/ssh_host_ecdsa_key.pub' if self.facts['system'] == 'Darwin': dsa_filename = '/etc/ssh_host_dsa_key.pub' rsa_filename = '/etc/ssh_host_rsa_key.pub' + ecdsa_filename = '/etc/ssh_host_ecdsa_key.pub' dsa = get_file_content(dsa_filename) rsa = get_file_content(rsa_filename) + ecdsa = get_file_content(ecdsa_filename) if dsa is None: dsa = 'NA' else: @@ -259,6 +268,10 @@ class Facts(object): rsa = 'NA' else: self.facts['ssh_host_key_rsa_public'] = rsa.split()[1] + if ecdsa is None: + ecdsa = 'NA' + else: + self.facts['ssh_host_key_ecdsa_public'] = ecdsa.split()[1] def get_pkg_mgr_facts(self): self.facts['pkg_mgr'] = 'unknown'