bash脚本,如何从ansible设置服务器架构

时间:2015-02-08 16:37:20

标签: bash ansible

我有一个bash脚本来构建一个rub .deb包,我想在其中使用服务器架构......

我安装了ansible并运行了ansible localhost -m setup,它给了我ansible事实......

> ansible localhost -m setup
localhost | success >> {
"ansible_facts": {
    "ansible_all_ipv4_addresses": [
        "10.10.5.200"
    ], 
    "ansible_all_ipv6_addresses": [
        "fe80::4c2:ccff:fe82:8d8c"
    ], 
    "ansible_architecture": "x86_64", 
    "ansible_bios_date": "06/02/2014",

...

我想使用检测到的架构" ansible_architecture":" x86_64"在我的fpm命令中的shell脚本中:

currently :
    fpm -s dir -t deb -n ruby$version -v $rubyversion -C $destdir \
  -p ruby-VERSION_ARCH~trusty.deb -d "libstdc++6 (>= 4.4.3)" \
  -d "libc6 (>= 2.6)" -d "libffi6 (>= 3.0.10)" -d "libgdbm3 (>= 1.8.3)" \
  -d "libncurses5 (>= 5.7)" -d "libreadline6 (>= 6.1)" \
  -d "libssl1.0.0 (>= 1.0.1)" -d "zlib1g (>= 1:1.2.2)" \
  -d "libyaml-0-2 (>= 0.1.4-2)" \
  usr/local/bin usr/local/lib usr/local/share/man usr/local/include

  #  VERSION_ARCH is giving me 'amd64'  and I would like to use 
  #  ansible_architecture ( which is detecting "x86_64"....

我可能不必使用安全事实来检测它......

#我试着在我的脚本开头写      $架构= uname -m  #但它确实给了我" x86_64"作为变量...

感谢您的建议

1 个答案:

答案 0 :(得分:1)

得到了它: 插入

architecture="$(uname -m)"
echo "architecture: $architecture"

在我的脚本开头并使用$ architecture作为参数