Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly-installed Driveclient agent skips registration #1

Open
ametts opened this issue Dec 18, 2014 · 1 comment
Open

Newly-installed Driveclient agent skips registration #1

ametts opened this issue Dec 18, 2014 · 1 comment

Comments

@ametts
Copy link

ametts commented Dec 18, 2014

Nice work on this ansible role -- but I noticed that my driveclient Agent wasn't registering, because the package is installed with a default /etc/driveclient/bootstrap.json file. Since the configuration step is skipped when the bootstrap.json file is "created", registration never happens.

I fixed it on my system by grepping for the presence of 'blank unless registered', which is a string that appears in a freshly-installed bootstrap file:

- name: Check if agent is registered
  command: grep blank-unless-registered /etc/driveclient/bootstrap.json
  register: result
  ignore_errors: true

- name: Configure the agent
  shell: >
    /usr/local/bin/driveclient --configure --apikey {{ driveclient_apikey }} --username {{ driveclient_username }}
  when: result.stdout == "blank-unless-registered"
  tags:
    - driveclient
    - rackspace
@MikeParkin
Copy link

I also hit this problem, however the solution above was not working for me.

This was because result.stdout was never equal to "blank-unless-registered" as it also contained the other characters on the same line.

I solved this by taking an md5 sum of the file then checking the m5 signature using stat.

- name: Check if agent is registerd
  stat: path=/etc/driveclient/bootstrap.json
  register: driveclient

- name: Configure the agent
  shell: >
    /usr/local/bin/driveclient --configure --apikey {{ driveclient_apikey }} --username {{ driveclient_username }}
  when: driveclient.stat.exists != true or driveclient.stat.md5 == "f4378257a01efae3cbbce4f456fd1d1b"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants