user762579
user762579

Reputation:

bash script , how to server architecture from ansible setup

I have a bash script to build a rub .deb package in which I would like to use the server architecture ...

I installed ansible and run ansible localhost -m setup , which gives me the ansible facts ...

> 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",

..

I would like to use detected architecture "ansible_architecture": "x86_64" in my shell script within my fpm command :

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"....

I may not have to use ansible facts to detect it ...

# I tried to write at the beginning of my script $architecture=uname -m # but it does gives me "x86_64" as a variable...

thanks for your suggestions

Upvotes: 2

Views: 689

Answers (1)

user762579
user762579

Reputation:

got it : inserting

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

at the beginning of my script and using $architecture as a parameter

Upvotes: 1

Related Questions