Ejemplo n.º 1
0
    def _configure_hcloud_client(self):
        self.api_token = self.get_option("token")
        if self.api_token is None:
            raise AnsibleError(
                "Please specify a token, via the option token or via environment variable HCLOUD_TOKEN")

        self.endpoint = os.getenv("HCLOUD_ENDPOINT") or "https://api.hetzner.cloud/v1"

        self.client = hcloud.Client(token=self.api_token,
                                    api_endpoint=self.endpoint,
                                    application_name="ansible-inventory",
                                    application_version=__version__)
Ejemplo n.º 2
0
    def _configure_hcloud_client(self):
        self.token_env = self.get_option("token_env")
        self.api_token = self.templar.template(
            self.get_option("token"), fail_on_undefined=False) or os.getenv(
                self.token_env)
        if self.api_token is None:
            raise AnsibleError(
                "Please specify a token, via the option token, via environment variable HCLOUD_TOKEN "
                "or via custom environment variable set by token_env option.")

        self.endpoint = os.getenv(
            "HCLOUD_ENDPOINT") or "https://api.hetzner.cloud/v1"

        self.client = hcloud.Client(token=self.api_token,
                                    api_endpoint=self.endpoint,
                                    application_name="ansible-inventory",
                                    application_version=__version__)